File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -26,13 +26,18 @@ class ScriptModifier(ModifierContext context) : Modifier(context)
26
26
{
27
27
private int count = 0 ;
28
28
29
+ private const string ScriptsDirectory = @"C:\Windows\Setup\Scripts" ;
30
+
31
+ private bool directoryCreated = false ;
32
+
29
33
public override void Process ( )
30
34
{
31
35
foreach ( Script script in Configuration . ScriptSettings . Scripts )
32
36
{
33
37
if ( ! string . IsNullOrWhiteSpace ( script . Content ) )
34
38
{
35
39
ScriptId scriptId = NewScriptId ( script ) ;
40
+ CreateScriptsDirectoryOnce ( ) ;
36
41
WriteScriptContent ( script , scriptId ) ;
37
42
CallScript ( script , scriptId ) ;
38
43
}
@@ -45,7 +50,17 @@ private ScriptId NewScriptId(Script script)
45
50
{
46
51
string name = $ "unattend-{ ++ count : X2} ";
47
52
string extension = script . Type . ToString ( ) . ToLowerInvariant ( ) ;
48
- return new ScriptId ( @$ "C:\Windows\Setup\Scripts\{ name } .{ extension } ", name ) ;
53
+ return new ScriptId ( @$ "{ ScriptsDirectory } \{ name } .{ extension } ", name ) ;
54
+ }
55
+
56
+ private void CreateScriptsDirectoryOnce ( )
57
+ {
58
+ if ( ! directoryCreated )
59
+ {
60
+ var appender = new CommandAppender ( Document , NamespaceManager , CommandConfig . Specialize ) ;
61
+ appender . ShellCommand ( $ "mkdir { ScriptsDirectory } ") ;
62
+ directoryCreated = true ;
63
+ }
49
64
}
50
65
51
66
private void WriteScriptContent ( Script script , ScriptId scriptId )
You can’t perform that action at this time.
0 commit comments