Login | |
|
 |
RE: Array to initialize - 2/13/2006 7:35:01 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
If you run this code, does it display the correct process name, or do you get an error: Option Explicit Dim objWMIService, objProcess, colProcess Dim strProcessKill, strInput Dim arrProcesses Dim arrMachines Dim strMachine Dim strProcess arrProcesses = Array("wrun.exe","crvw.exe","six_agnt.exe") arrMachines = Array("QA1","QA2","QA3","QA4") For Each strMachine In arrMachines Set objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" _& arrMachines(strMachine) & "\root\cimv2") For Each strProcess In arrProcesses Set colProcess = objWMIService.ExecQuery _("Select * from Win32_Process Where Name = " & arrProcesses(strProcess) ) For Each objProcess in colProcess Msgbox "Winrunner processes:" & arrProcesses(strProcess) MsgBox objProcess.Name Next WSCript.Echo "Just killed process " & arrProcesses_& " on " & arrMachines(strMachine) Next Next WScript.Quit ' End of WMI Example of a Kill Process
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Array to initialize - 2/13/2006 8:19:34 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
Oops...straight syntaxt error that I didn't see...try this code: Option Explicit Dim objWMIService, objProcess, colProcess Dim strProcessKill, strInput Dim arrProcesses Dim arrMachines Dim strMachine Dim strProcess arrProcesses = Array("wrun.exe","crvw.exe","six_agnt.exe") arrMachines = Array("QA1","QA2","QA3","QA4") For Each strMachine In arrMachines Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & arrMachines(strMachine) & "\root\cimv2") For Each strProcess In arrProcesses Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = " & arrProcesses(strProcess) For Each objProcess in colProcess Msgbox "Winrunner processes:" & arrProcesses(strProcess) objProcess.Terminate() Next WSCript.Echo "Just killed process " & arrProcesses & " on " & arrMachines(strMachine) Next Next WScript.Quit ' End of WMI Example of a Kill Process
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Array to initialize - 2/13/2006 8:31:12 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
You were trying to use the machine name as the index of the array to get the machine name. Try this: Option Explicit Dim objWMIService, objProcess, colProcess Dim strProcessKill, strInput Dim arrProcesses Dim arrMachines Dim strMachine Dim strProcess arrProcesses = Array("wrun.exe","crvw.exe","six_agnt.exe") arrMachines = Array("QA1","QA2","QA3","QA4") For Each strMachine In arrMachines Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strMachine & "\root\cimv2") For Each strProcess In arrProcesses Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & strProcess & "'" For Each objProcess in colProcess MsgBox "Winrunner processes:" & arrProcesses(strProcess) objProcess.Terminate() Next WSCript.Echo "Just killed process " & arrProcesses & " on " & arrMachines(strMachine) Next Next WScript.Quit ' End of WMI Example of a Kill Process
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|