Script to connect to WMI on a remote computer

Asked By 20 points N/A Posted on -
qa-featured

Dear friends

What is the script to connect to WMI on remote computer? How do i connect WMI using WMIC?

Thanks

SHARE
Answered By 5 points N/A #109741

Script to connect to WMI on a remote computer

qa-featured

Hi Ariel, 

Try this VBScript to connect to remote computers

 

strComputer = "<remote_computer_name>"

strDomain = "<domain>"

 

Wscript.StdOut.Write "Please remote computer name:"

strComputer = Wscript.Stdln.Readline

Wscript.StdOut.Write "Please enter domain:"

strDomain = Wscript.Stdln.Readline

 

Wscript.StdOut.Write "Please enter your user name:"

strUserName = Wscript.StdIn.ReadLine

Set objPassword = CreateObject("ScriptPW.Password")

Wscript.StdOut.Write "Please enter your password:"

strPassword = objPassword.GetPassword()

Set objScr = CreateObject("WbemScripting.SWbemLocator")

Set objSvc = objScr .ConnectServer(strComputer, _

"rootcimv2", _

     strUserName, _

     strPassword, _

     "MS_409", _

     "ntlmdomain:" + strDomain)

After connection has been establish you can know process to desired transactions you want on the remote computer such as enumerating running processes.

To use WMIC take a look at this page below:

 

https://technet.microsoft.com/en-us/library/bb742610.aspx

 

I hope it helps.

 

 

Related Questions