Allow the prevention of sleep mode

This commit is contained in:
Manuel Thalmann 2023-07-29 02:58:00 +02:00
parent 79d3fd4d2d
commit 3578bf6407
2 changed files with 16 additions and 0 deletions
scripts/Windows/Scripts

View file

@ -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;
}
}
}