Extension: Add Power Actions script

This commit is contained in:
Belim authored and GitHub committed 2025-09-12 21:15:59 +02:00
1 parent c78b71bdc5
commit 55a65e0bce
1 file changed
+43
+43
View File
@@ -0,0 +1,43 @@
# Power Actions – Restart Explorer, Restart, Shutdown, Logoff, Sleep, Hibernate
# Host: silent
# Options: Restart Explorer; Restart PC; Shutdown PC; Log off; Sleep; Hibernate
param([string]$choice)
switch ($choice) {
"Restart Explorer" {
Write-Output "Restarting Explorer..."
Stop-Process -Name explorer -Force
Start-Process explorer.exe
}
"Restart PC" {
Write-Output "Restarting computer..."
Restart-Computer -Force
}
"Shutdown PC" {
Write-Output "Shutting down computer..."
Stop-Computer -Force
}
"Log off" {
Write-Output "Logging off current user..."
shutdown.exe /l
}
"Sleep" {
Write-Output "Putting system to sleep..."
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
}
"Hibernate" {
Write-Output "Hibernating system..."
rundll32.exe powrprof.dll,SetSuspendState Hibernate
}
default {
Write-Output "Unknown option: $choice"
}
}