WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Lock NT Server

 Keywords: Lock NT Server 

Question:

Does any one know how to lock remote NT Server ?

Answer:

There is a Win32 API function that can be used to lock the local workstation, and it would be easily callable via DllCall(). However, this function doesn't allow you to lock a remote workstation, and there doesn't seem to be an API function that can lock a remote workstation.

You might consider writing a little script that calls the LockWorkstation() API and then have the script executed on a remote system.

I wrote this when trying to wade through the Platform SDK to see if there was a way to determine whether the workstation was locked:

;Lock workstation.  NT-based OS's only.
LockWS=DllCall(StrCat(DirWindows(1),"User32.dll"),long:"LockWorkStation")
If LockWS==0 
   LockMsg="Failed to lock workstation"
Else
   LockMsg="Workstation lock successful"
EndIf
Message ("Lock Workstation",LockMsg)
Exit 

Another option would be to do the following:

run("rundll32.exe", "user32.dll,LockWorkStation")
TimeDelay(3)

LockDetectionTile = strcat(random(99999),"LockDetectionWindow",random(99999))
BoxesUp("450,450,550,525",@normal)
BoxCaption(1,LockDetectionTile)
BoxButtonDraw(1,1,"Click Here","0,0,1000,1000")
BoxDataTag(1,"clickme")
while !BoxButtonStat(1,1)
TimeDelay(.1)
SendKeysTO(LockDetectionTile,"~")
endwhile
boxdataclear(1,"clickme")
boxdestroy(1)

TimeDelay(2)
message("Attention","Looks like the workstation is unlocked now.")
exit

Article ID:   W15518
File Created: 2003:05:13:11:28:28
Last Updated: 2003:05:13:11:28:28