Locking your remote computer

Using simple VB Script you can lock your computer. Following is the code to lock the computer


 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

strComputer = "<Remote_computer_Name>"
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")

Error = objWMIService.Create _
    ("cscript path_to_copy_file", null, null, _
        intProcessID)

In Above code replace:
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

Golang: Http POST Request with JSON Body example

Go standard library comes with "net/http" package which has excellent support for HTTP Client and Server.   In order to post JSON ...