Skip to content

Instantly share code, notes, and snippets.

@ibrezm1
Created June 22, 2023 07:06
Show Gist options
  • Save ibrezm1/0d61a8a6d41dd7f0ccec136d8b6aca0c to your computer and use it in GitHub Desktop.
Save ibrezm1/0d61a8a6d41dd7f0ccec136d8b6aca0c to your computer and use it in GitHub Desktop.
Vbscript csvript keep unlocked till time
Sub forceCScriptExecution
Dim Arg, Str
If Not LCase( Right( WScript.FullName, 12 ) ) = "\cscript.exe" Then
For Each Arg In WScript.Arguments
If InStr( Arg, " " ) Then Arg = """" & Arg & """"
Str = Str & " " & Arg
Next
CreateObject( "WScript.Shell" ).Run _
"cscript //nologo """ & _
WScript.ScriptFullName & _
""" " & Str
WScript.Quit
End If
End Sub
forceCScriptExecution
set wsc = CreateObject("WScript.Shell")
' Set target end time (9 PM)
Dim targetHour
targetHour = 21
' Loop until the target end time is reached
Do While Hour(Now) < targetHour
' Move the mouse cursor to prevent the screen from locking
wsc.SendKeys ("{SCROLLLOCK 2}")
wscript.stdout.write "."
WScript.Sleep (60*1000)
Loop
' Cleanup and end the script
Set WshShell = Nothing
WScript.Quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment