twp Posted February 20, 2014 Posted February 20, 2014 Have tried a couple of functions, shown below, but none seem to work at deployment via SCCM (2012 sp1). Does anyone have a solution for this? Need to check at the beginning of the script if the computer is locked and if so abort the script with a predefined error code. #include <APIConstants.au3> #include <WinAPIEx.au3> Sleep(5000) If _IsLocked() Then ConsoleWrite('Workstation Is Locked.' & @CRLF) Exit 666 Else ConsoleWrite('Workstation Not Locked.' & @CRLF) EndIf Func _IsLocked() Local $fIsLocked = False Local Const $hDesktop = _WinAPI_OpenDesktop('Default', $DESKTOP_SWITCHDESKTOP) If @error = 0 Then $fIsLocked = Not _WinAPI_SwitchDesktop($hDesktop) _WinAPI_CloseDesktop($hDesktop) EndIf Return $fIsLocked EndFunc ;==>_IsLocked Sleep(5000) _WinLocked() MsgBox(0, "Test01", "Workstation Not Locked") Func _WinLocked() $res=0 $h=DllCall("User32.dll","int","OpenInputDesktop","int",0,"int",0,"int",0x0001) if $h[0]=0 then $res=1 DllCall("user32.dll", "int", "CloseDesktop", "int", $h[0]) If $res = 1 Then MsgBox(0, "Test02", "Workstation Locked") exit($res) ;1=computer locked, 0=unlocked EndIf EndFunc They work before I turn them into EXE files, but after that they only work when run as administrator and when I deploy the _WinLocked function via SCCM the script exits directly. Is there a function that can work when run as System via SCCM?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now