Skip to content

Commit

Permalink
Move scripts from ‘C:\Windows\Temp’ to ‘C:\Windows\Setup\Scripts’
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneegans committed Nov 24, 2024
1 parent 2bbf814 commit dae226d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
10 changes: 5 additions & 5 deletions modifier/Bloatware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Save(BloatwareModifier parent)
{
return;
}
string scriptPath = @$"C:\Windows\Temp\{BaseName}.ps1";
string scriptPath = @$"C:\Windows\Setup\Scripts\{BaseName}.ps1";
parent.AddTextFile(GetRemoveCommand(), scriptPath);
parent.SpecializeScript.InvokeFile(scriptPath);
}
Expand All @@ -38,7 +38,7 @@ private string GetRemoveCommand()
sw.WriteLine($"$filterCommand = {FilterCommand};");
sw.WriteLine($"$removeCommand = {RemoveCommand};");
sw.WriteLine($"$type = '{Type}';");
sw.WriteLine($@"$logfile = 'C:\Windows\Temp\{BaseName}.log';");
sw.WriteLine($@"$logfile = 'C:\Windows\Setup\Scripts\{BaseName}.log';");
return sw.ToString() + Util.StringFromResource("RemoveBloatware.ps1");
}

Expand Down Expand Up @@ -80,7 +80,7 @@ class PackageRemover : Remover<PackageBloatwareStep>
}
""";

protected override string BaseName => "remove-packages";
protected override string BaseName => "RemovePackages";

protected override string Type => "Package";
}
Expand Down Expand Up @@ -115,7 +115,7 @@ class CapabilityRemover : Remover<CapabilityBloatwareStep>
}
""";

protected override string BaseName => "remove-caps";
protected override string BaseName => "RemoveCapabilities";

protected override string Type => "Capability";
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class FeatureRemover : Remover<OptionalFeatureBloatwareStep>
}
""";

protected override string BaseName => "remove-features";
protected override string BaseName => "RemoveFeatures";

protected override string Type => "Feature";
}
Expand Down
4 changes: 2 additions & 2 deletions modifier/Wdac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ void NewPathRule(string path, RuleType type)
} catch {
$_;
}
) *>&1 | Out-File -Append -FilePath "$env:TEMP\wdac.log";
) *>&1 | Out-File -Append -FilePath 'C:\Windows\Setup\Scripts\Wdac.log"';
""");

string ps1File = @"C:\Windows\Setup\Scripts\wdac.ps1";
string ps1File = @"C:\Windows\Setup\Scripts\Wdac.ps1";
AddTextFile(sw.ToString(), ps1File);
SpecializeScript.InvokeFile(ps1File);
}
Expand Down
2 changes: 1 addition & 1 deletion modifier/Wifi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void AddWifiProfile(IProfileWifiSettings settings)
throw new ConfigurationException($"WLAN profile XML is invalid: {e.Message}");
}

string xmlfile = @"C:\Windows\Setup\Scripts\wifi.xml";
string xmlfile = @"C:\Windows\Setup\Scripts\Wifi.xml";
AddXmlFile(profile, xmlfile);

SpecializeScript.Append($"""
Expand Down
5 changes: 1 addition & 4 deletions resource/ExtractScripts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ param(
[xml] $Document
);

$scriptsDir = 'C:\Windows\Setup\Scripts\';
foreach( $file in $Document.unattend.Extensions.File ) {
$path = [System.Environment]::ExpandEnvironmentVariables(
$file.GetAttribute( 'path' )
);
if( $path.StartsWith( $scriptsDir ) ) {
mkdir -Path $scriptsDir -ErrorAction 'SilentlyContinue';
}
mkdir -Path( $path | Split-Path -Parent ) -ErrorAction 'SilentlyContinue';
$encoding = switch( [System.IO.Path]::GetExtension( $path ) ) {
{ $_ -in '.ps1', '.xml' } { [System.Text.Encoding]::UTF8; }
{ $_ -in '.reg', '.vbs', '.js' } { [System.Text.UnicodeEncoding]::new( $false, $true ); }
Expand Down
2 changes: 1 addition & 1 deletion resource/VBoxGuestAdditions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
}
}
'VBoxGuestAdditions.iso is not attached to this VM.';
} *>&1 >> "$env:TEMP\VBoxGuestAdditions.log";
} *>&1 >> 'C:\Windows\Setup\Scripts\VBoxGuestAdditions.log';
2 changes: 1 addition & 1 deletion resource/VirtIoGuestTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
}
}
'VirtIO Guest Tools image (virtio-win-*.iso) is not attached to this VM.';
} *>&1 >> "$env:TEMP\VirtIoGuestTools.log";
} *>&1 >> 'C:\Windows\Setup\Scripts\VirtIoGuestTools.log';

0 comments on commit dae226d

Please sign in to comment.