Recently received a difference: writing a remote installation application. Because there is a project to be used for network management, you need to install a client on each terminal. Consider using NetBIOS when you start, but you can't solve some problems. It should be that your skill is not enough. Later, the WMI can implement such functions, not only can run the application remotely, but also copied local files to the remote machine, but the premise is that the remote machine must have a shared directory. Because the interface on the WMI on different operating systems may be different, it cannot be guaranteed.
The method of running the script is to copy the following scripts to the notepad, save it as a venque name of the VBS, and then run under the console:
CScript script file name
Or double-click the script file to run directly
'------------------------------------- ---------- 'Remote Execution Strcomputer = "192.168.0.30"
Set objswbemlocator = createObject ("wbemscripting.swbemlocator") set objswbemservices = objswbemlocator.connectServer_ (StrComputer, "Root / Cimv2", "Fabrikam / Administrator",
"85558418")
Set objnewprocess = objswbemservices.get ("Win32_Process")
'Objwmiservices.security_.impersonationLevel = 3
Error = ObjneWProcess.create _ ("c: /tmp.bat", null, null, _ intprocessid) wscript.echo errorwscript.echo intProcessID
If you do not return an error, you can use the following script to enumerate the process running on the remote machine.
'------------------------------------- ----------- 'Enumeration Remote Process STRComputer = "192.168.0.30"
Set objswbemlocator = createObject ("wbemscripting.swbemlocator") set objswbemservices = objswbemlocator.connectServer_ (StrComputer, "Root / Cimv2", "Fabrikam / Administrator",
"85558418")
SET COLSWBEMOBJECTSET = _ ObjswbemServices.execQuery ("Select * from win32_process") for Each ObjProcess In ColSwbemObjectSet Wscript.echo "Process Name:" & objProcess.name Next
Because there is a default shared disk on Windows platform, you can copy the application you need to run to C $ on the destination machine, of course, you can also be other shared folders.
'------------------------------------- ----------- 'remote copy file strComputer = "192.168.0.30" Const OverwriteExisting = TRUESet objSWbemLocator = CreateObject ( "WbemScripting.SWbemLocator") Set objSWbemServices = objSWbemLocator.ConnectServer _ (strComputer, "root / cimv2 "," Fabrikam / Administrator ",
"85558418")
'Set objFSO = objSWbemServices.Get ( "Scripting.FileSystemObject") Set objFSO = CreateObject ( "Scripting.FileSystemObject") objFSO.CopyFile "C: /va.log", _ "//" strComputer "/ C $ / "OVERWRITEEXISTING
After copying, you can run the following script, check if the file is present on the machine '------------------------------- ---------------------------- 'Search Specific Extensions StrComputer = "192.168.0.30" const overwriteexisting = TRUE
Set objswbemlocator = createObject ("wbemscripting.swbemlocator") set objswbemservices = objswbemlocator.connectServer_ (StrComputer, "Root / Cimv2", "Fabrikam / Administrator",
"85558418")
Set colfiles = objswbemservices.execquery _ ("Select * from custom_datafile where extension = 'log'") for Each Objfile in colfiles wscript.echo objfile.name Next
Because I need to install it very small, but just register a DLL, the above script is enough to meet my needs, and this script is written for network administrators, so you have to get the account and password of the administrator on the remote machine. Not a difficult thing.
If you need more information, you can go to the script center to get.