TomRiddle
-
Total Posts
:
620
- Scores: 12
-
Reward points
:
0
- Joined: 2/7/2008
- Location: Australia
-
Status: offline
|
Convert Winbatch script to vbs?
Monday, August 18, 2008 11:31 PM
( permalink)
I am trying to be able to detect if a XP workstation is locked and apparently this code does it. http://www.winbatch.com Do you think it would be possible to port to vbscript? #definefunction IsMachineLocked()
dill = strcat(dirwindows(1),"user32.dll") ;Set the path to the User32.dll
lock_state = @false ;Initialize variable (Default return value = @false)
dll_hand = dllload(dill) ;Retrieve handle to $dill
desktop_hand = dllcall(dll_hand,long:"OpenInputDesktop",word:0,word:0,word:0) ;Retrieve handle of current desktop
if desktop_hand < 1 ;If $desktop_hand < 1 (NULL or 0), then machine is locked.
lock_state = @true ;Set $lock_state to true if $desktop_hand > 0
endif
dllfree(dll_hand) ;Free the DLL handle
return(lock_state) ;Return the lock state
#endfunction
<message edited by TomRiddle on Monday, August 18, 2008 11:42 PM>
|
|
|
|
TomRiddle
-
Total Posts
:
620
- Scores: 12
-
Reward points
:
0
- Joined: 2/7/2008
- Location: Australia
-
Status: offline
|
RE: Convert Winbatch script to vbs?
Tuesday, November 04, 2008 11:55 PM
( permalink)
Don't worry vbscript can't do it and Winbatch sux you have to pay for it. Besides I got hold of some c# books and knocked up a little command line utility that does it instead. I am still actively scripting but my aspirations are mastering c# and Powershell one day. But both seem to be a more massive jump than what vbscript ever was.
|
|
|
|
mbouchard
-
Total Posts
:
2110
- Scores: 29
-
Reward points
:
0
- Joined: 5/15/2003
- Location: USA
-
Status: offline
|
RE: Convert Winbatch script to vbs?
Wednesday, November 05, 2008 12:47 AM
( permalink)
I don't remember seeing this back in August, but it can also be done via AutoIT, which is free. Found this on AutoIT's forums and is just a snippet from a much larger script ; If the system is locked then reset the timer checkLock() Func checkLock() $locked=DllCall("user32","Long","OpenInputDesktop") If $locked[0] = 0 Then $start = TimerInit() EndFunc
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
|
|
TomRiddle
-
Total Posts
:
620
- Scores: 12
-
Reward points
:
0
- Joined: 2/7/2008
- Location: Australia
-
Status: offline
|
RE: Convert Winbatch script to vbs?
Wednesday, November 05, 2008 11:56 AM
( permalink)
Thanks Mike, I will check out AutoIT
|
|
|
|