Skip to content

Commit 383ea77

Browse files
committed
Add sensitive files option
1 parent 2b9f587 commit 383ea77

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Program.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ static async Task Main(string[] args)
152152
List<Schneegans.Unattend.ProcessorArchitecture> defaultArchitectures = new List<Schneegans.Unattend.ProcessorArchitecture>();
153153
defaultArchitectures.Add(Schneegans.Unattend.ProcessorArchitecture.amd64);
154154

155+
bool noSensitiveFiles = false;
156+
155157
Console.WriteLine($"UnattendGen{(File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DT")) ? " for DISMTools" : "")}, version {Assembly.GetEntryAssembly().GetName().Version.ToString()}");
156158
Console.WriteLine("-------------------------------------------------");
157159
Console.WriteLine($"Program: (c) {GetCopyrightTimespan(2024, DateTime.Today.Year)}. CodingWonders Software\nLibrary: (c) {GetCopyrightTimespan(2024, DateTime.Today.Year)}. Christoph Schneegans");
@@ -765,6 +767,11 @@ static async Task Main(string[] args)
765767
generator.SystemComponents = defaultComponents;
766768
}
767769
}
770+
else if (cmdLine.StartsWith("--nosensitivefiles", StringComparison.OrdinalIgnoreCase))
771+
{
772+
Console.WriteLine("INFO: removing sensitive files after installation");
773+
noSensitiveFiles = true;
774+
}
768775
if (cmdLine != Assembly.GetExecutingAssembly().Location)
769776
DebugWrite($"Successfully parsed command-line switch {cmdLine}", (debugMode | Debugger.IsAttached));
770777
}
@@ -799,6 +806,8 @@ static async Task Main(string[] args)
799806
generator.processorArchitectures = defaultArchitectures;
800807
}
801808

809+
generator.noSensitiveFiles = noSensitiveFiles;
810+
802811
await generator.GenerateAnswerFile(targetPath != "" ? targetPath : "unattend.xml");
803812
}
804813
}
@@ -893,6 +902,8 @@ public enum SystemTelemetry
893902

894903
public List<SystemComponent>? SystemComponents = new List<SystemComponent>();
895904

905+
public bool noSensitiveFiles;
906+
896907
public async Task GenerateAnswerFile(string targetPath)
897908
{
898909
await Task.Run(() =>
@@ -1092,7 +1103,8 @@ Configuration.Default with
10921103
ParallelsTools = (virtualMachine == VirtualMachineSolution.Parallels),
10931104
UseConfigurationSet = UseConfigSet,
10941105
HidePowerShellWindows = HideScriptWindows,
1095-
DeleteWindowsOld = true
1106+
DeleteWindowsOld = true,
1107+
KeepSensitiveFiles = !noSensitiveFiles
10961108
}
10971109
);
10981110
/*
@@ -1134,6 +1146,7 @@ Configuration.Default with
11341146
Console.WriteLine("Pausing execution state and exiting after 5 seconds...");
11351147

11361148
Thread.Sleep(5000);
1149+
Environment.Exit(ex.HResult);
11371150
}
11381151
});
11391152
}

0 commit comments

Comments
 (0)