Skip to content

Instantly share code, notes, and snippets.

@ohsyln
Last active September 12, 2022 06:50
Show Gist options
  • Save ohsyln/351895a356a61ce7dd17163e0054c44f to your computer and use it in GitHub Desktop.
Save ohsyln/351895a356a61ce7dd17163e0054c44f to your computer and use it in GitHub Desktop.
Prevent screen lock when idle due to company policy (Win)
REM Sends a keystroke at fixed intervals to prevent screen lock
REM Bypasses most group policies that prevent execution of scripts in general
REM As long as you can run "cmd.exe" and "mshta.exe", this should work
REM 1) Open cmd.exe
REM 2) Copy-paste the command in cmd.exe and press enter
for /L %N in () do mshta vbscript.Execute("CreateObject(""wscript.shell"").sendkeys(""{SCROLLLOCK 2}"")")(close.window) && ping localhost -n 119 1>nul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment