Allow the prevention of sleep mode
This commit is contained in:
parent
79d3fd4d2d
commit
3578bf6407
2 changed files with 16 additions and 0 deletions
|
@ -14,6 +14,7 @@ function Invoke-WindowsInstallation([Context] $context)
|
|||
|
||||
$null = Enable-WindowsOptionalFeature -Online -All -FeatureName "NetFx3";
|
||||
|
||||
$context.PreventSleepMode();
|
||||
. "$configPath/Windows/Install.ps1" $context;
|
||||
. "$configPath/Explorer/Install.ps1" $context;
|
||||
. "$configPath/OpenSSH/Install.ps1" $context;
|
||||
|
|
|
@ -370,10 +370,25 @@ class Context {
|
|||
exit;
|
||||
}
|
||||
|
||||
[void] PreventSleepMode() {
|
||||
$performanceScheme = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c";
|
||||
$currentScheme = [regex]::Match((powercfg /GETACTIVESCHEME), "Power Scheme GUID: ([0-9a-f-]) ").Groups[1].Value;
|
||||
|
||||
if ($currentScheme -ne $performanceScheme) {
|
||||
$this.Set("Power Scheme", $currentScheme);
|
||||
powercfg /S 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c;
|
||||
}
|
||||
}
|
||||
|
||||
[void] Cleanup() {
|
||||
$this.DeregisterNewUserReboot();
|
||||
$this.RemoveAutologin();
|
||||
$this.SetUACState($true);
|
||||
Remove-Item $($this.EnsureConfigKey().PSPath);
|
||||
$originalScheme = $this.Get("Power Scheme");
|
||||
|
||||
if ($originalScheme) {
|
||||
powercfg /S $originalScheme;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue