Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vbscript to close multiple processes

Status
Not open for further replies.

Count430

Programmer
Apr 26, 2002
127
US
Hello all, I recently pulled a script to shut down a process, however when you achieve one thing more comes along.

I have the following lines of code which shut down a single process. Whenever I attempt to add more than one value to my select statement it wont shut down any processes.

Here is the code I'm using which was on the microsoft script site.


Set oWmi = GetObject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")
query = "Select * from Win32_Process where name = 'notepad.exe'"
'query = "Select * from Win32_Process where name like Iexplore.exe"
Set wql = oWmi.execQuery(query)
For each item In wql
item.terminate()
next
Set wql = Nothing
Set owmi = Nothing


This code only works for a single process and it's becomming a hassle because Ive used Select to query more than one item in the past :(
 
Does this work?
'query = "Select * from Win32_Process where " _
& " name like 'Iexplore.exe'" _
& " OR name like 'Notepad.exe'"


[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
I tried these and they return the same errors, I think I may need to list the processes as constants and then try to group them together in an array.

From the array call the services to shutdown, this sounds like alogical approach, now the only thing to do is learn to create the array.

Wow I better throw on a pot of coffee...

thanks bunches, it's just strange how vbscript handles the select statement.

Next I'll look into the platform SDK to investigate further.
 
it's just strange how vbscript handles the select statement{/i]
FYI: the select statement isn't handle by VBScript, but by WMI.
 
Hello Count430,

What is your OS? Like-statement is only available to xp and server 2003.

regards - tsuji
 
That's interesting, I've been looking for the correct version of platform SDK in order to obtain the right syntax and methods.

I'll give it a try thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top