From b03ad2005ca981bbe24f94cdb40c3a30ddcfc7d7 Mon Sep 17 00:00:00 2001 From: Mr-cool08 <82951310+Mr-cool08@users.noreply.github.com> Date: Sat, 30 Jul 2022 18:00:05 +0200 Subject: [PATCH] changed run.vbs file --- run.vbs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/run.vbs b/run.vbs index bd5afb5..3e25376 100644 --- a/run.vbs +++ b/run.vbs @@ -1,5 +1,37 @@ Set objShell = Wscript.CreateObject ("Wscript.shell") -do +dim islocked + + + call checklock + + + +'================================= +'Functions +'================================= + +function checklock + Dim computer : computer = "." + + If WScript.Arguments.Count = 1 Then + computer = WScript.Arguments(0) + End If + + If locked(computer) Then + Wscript.Quit + Else + do WScript.Sleep(600000) objShell.Run "python C:\users\%username%\usercheck\check.py" -loop \ No newline at end of file +loop + wscript.sleep 3000 'for debugging - allow time to enter lock screen + End If +end function + + +Function locked(computer) + Dim wmi : Set wmi = GetObject("winmgmts://" & computer & "/root/cimv2") + Dim lockapp_count : lockapp_count = wmi.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'lockapp.exe'").Count + Dim explorer_count : explorer_count = wmi.ExecQuery ("SELECT * FROM Win32_Process WHERE Name = 'explorer.exe'").Count + locked = (lockapp_count >= explorer_count) +End Function