-
Star
(168)
You must be signed in to star a gist -
Fork
(41)
You must be signed in to fork a gist
-
-
Save jamesfreeman959/231b068c3d1ed6557675f21c0e346a9c to your computer and use it in GitHub Desktop.
# Useful references: | |
# | |
# https://superuser.com/questions/992511/emulate-a-keyboard-button-via-the-command-line | |
# https://ss64.com/vb/sendkeys.html | |
# https://social.technet.microsoft.com/Forums/windowsserver/en-US/96b339e2-e9da-4802-a66d-be619aeb21ac/execute-function-one-time-in-every-10-mins-in-windows-powershell?forum=winserverpowershell | |
# https://learn-powershell.net/2013/02/08/powershell-and-events-object-events/ | |
# | |
# Future enhancements - use events rather than an infinite loop | |
$wsh = New-Object -ComObject WScript.Shell | |
while (1) { | |
# Send Shift+F15 - this is the least intrusive key combination I can think of and is also used as default by: | |
# http://www.zhornsoftware.co.uk/caffeine/ | |
# Unfortunately the above triggers a malware alert on Sophos so I needed to find a native solution - hence this script... | |
$wsh.SendKeys('+{F15}') | |
Start-Sleep -seconds 59 | |
} |
Nevermind! the .exe works just fine. I've recently run into other limitations of Windows Home so I was projecting blame to Home b4 even digging.
Thank you @jheinrichs79
Is keepawake.ps1 intended to work on Windows Home? I got unauthorized error. This work provisioned laptop really sucks!!
File C:\Users\user1\Documents\MyScripts\keepawake.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. + CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnauthorizedAccess
p.s. apologies probably not in the correct venue. Stumbled on this thread looking for solution. former programmer but 90's-00s
@noviceboomer - Any time you run any Powershell script you need to make sure your security policies allow for you to run a powershell script. You most likely have a policy that states not to run a public or non-sign script. Google "Set-ExecutionPolicy" and find the setting that will work for you. Also when you download a script from the internet you need to right click it and say that you trust it as it came from an untrusted network (internet).
Is keepawake.ps1 intended to work on Windows Home? I got unauthorized error. This work provisioned laptop really sucks!!
File C:\Users\user1\Documents\MyScripts\keepawake.ps1 cannot be loaded because running scripts is disabled on this
system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
p.s. apologies probably not in the correct venue. Stumbled on this thread looking for solution. former programmer but 90's-00s