' example to run any executable program in commandline mode
Set objWshNet = CreateObject("Wscript.Network")
strServer = objWshNet.ComputerName
paraCount=WScript.Arguments.Count
If paraCount <> 3 Then
Wscript.Echo "Usage:"
Wscript.Echo "cscript //nologo test.vbs /Machine:<MachineName> /Admin:<AdministratorName> /Pwd:<Passworkd>"
Else
strComputer = Wscript.Arguments.Named.Item("Machine")
strAdmin = Wscript.Arguments.Named.Item("Admin")
strPassword = Wscript.Arguments.Named.Item("Pwd")
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
If UCase(strComputer) = UCase(strServer) Then
Set objService = objLocator.ConnectServer(, "Root\cimv2")
Else
Set objService = objLocator.ConnectServer(strComputer, "Root\cimv2", strAdmin,strPassword)
End If
strExe = "cmd /K C:\WINDOWS\system32\Notepad.exe"
'Obtain the Win32_Process class of object.
Set objProcess = objService.Get("Win32_Process")
Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe
'Execute the program now at the command line.
Set strShell = objService.ExecMethod("Win32_Process", "Create", objProgram)
WScript.echo "Created: " & strExe & " on " & strComputer
WSCript.Quit
End If
posted on 2007-04-29 16:04
GuangMing Lan 阅读(292)
评论(0) 编辑 收藏 引用