Extension: Add Power Actions script
This commit is contained in:
1 parent
c78b71bdc5
commit
55a65e0bce
1 file changed
+43
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user