Skip to content

Instantly share code, notes, and snippets.

@mfedatto
Forked from valdergallo/noSleep.vbs
Last active November 29, 2022 02:45
Show Gist options
  • Save mfedatto/8fbaf7b66a1c0eb2ff4512f01e459af7 to your computer and use it in GitHub Desktop.
Save mfedatto/8fbaf7b66a1c0eb2ff4512f01e459af7 to your computer and use it in GitHub Desktop.
Script to make windows stop to sleep using VBscript
Dim objWScript : Set objWScript = CreateObject("WScript.Shell")
Dim blnConsole : blnConsole = False
Dim dtmStartedAt : dtmStartedAt = Now()
If InStr(1, WScript.FullName, "cscript", vbTextCompare) Then
blnConsole = True
End If
Do
Call Shout()
Call WScript.Sleep(5 * 60 * 1000)
Call objWScript.SendKeys("{NUMLOCK}")
Loop
Set objWScript = Nothing
Function Shout
If blnConsole Then
Call WScript.Echo(dtmStartedAt & " ~ " & Now())
End If
End Function
@mfedatto
Copy link
Author

I recommend using it on a command line tool through cscript, so it is easy to stop by interrupting the run with a Ctrl + C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment