On Error Resume Next
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%windir%\System32\rundll32.exe user32.dll,LockWorkStation"
Now the challenge is, how can you use this script to lock the remote computer. This is pretty simple, using VB Script, copy this lock script to a remote computer, then execute the script on remote computer, this will lock the remote computer.
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "<LockScriptPath>", _"\\<Remote_computer_Name>\path_to_copy_file", OverWriteExisting
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
Error = objWMIService.Create _
("cscript path_to_copy_file", null, null, _
intProcessID)
LockScriptPath: With the local machine path of lock script ( code given above)
Remote_computer_Name : Name or IP address of remote computer to lock.
path_to_copy_file : Path on remote computer where you can copy the lock script.
No comments:
Post a Comment