Last active
October 27, 2021 05:14
-
-
Save duchenpaul/332dc04c66b424b1abfaaf4f3268ba52 to your computer and use it in GitHub Desktop.
A simple vbs to prevent your PC from policy screen lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -AssemblyName System.Windows.Forms | |
New-Variable -name INTERVAL -Value (60 * 2) -Option Constant -Description 'for 5mins lock default' | |
get-date | |
echo `start` | |
while ($true) { | |
$key = '{SCROLLLOCK}' | |
get-date | |
echo "press key $key`n" | |
try { | |
[System.Windows.Forms.SendKeys]::SendWait($key) | |
[System.Windows.Forms.SendKeys]::SendWait($key) | |
} | |
catch { | |
Write-Host "An error occurred:" | |
Write-Host $_ | |
Write-Host $_.ScriptStackTrace | |
} | |
sleep -s $INTERVAL | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim objResult | |
Set objShell = WScript.CreateObject("WScript.Shell") | |
Do While True | |
Wscript.Sleep(3000) | |
objResult = objShell.sendkeys("{SCROLLLOCK}") | |
Wscript.Sleep(100) | |
objResult = objShell.sendkeys("{SCROLLLOCK}") | |
Wscript.Sleep(100) | |
objResult = objShell.sendkeys("{SCROLLLOCK}") | |
Wscript.Sleep(100) | |
objResult = objShell.sendkeys("{SCROLLLOCK}") | |
Loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment