Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Scripting neophyte - why does this simple script not work?

Reply
 
Old 01-12-2009   #1 (permalink)
Stephen Mulholland


 
 

Scripting neophyte - why does this simple script not work?


Hi all

I know nothing at all about scripting, I've just copied this from a
website.

All I want to do is to kill a process which is running on several XP
PCs - let's call it "rogueprocess.exe". If I look at Task Manager on
the Processes tab "rogueprocess.exe" is running. And I want to kill it
stone dead.

Here's the script :


'****************************************************************************
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'rogueprocess.exe'"

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
'**************************************************************************


If I run this script, it doesn't kill the process. What is wrong with
the script?

Thanks for any assistance.

Stephen

My System SpecsSystem Spec
Old 01-12-2009   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Scripting neophyte - why does this simple script not work?


"Stephen Mulholland" <mulhollands@xxxxxx> wrote in message
news:4736d787-23ea-4ba4-834f-ef3b68eb6aac@xxxxxx
Quote:

>
> Hi all
>
> I know nothing at all about scripting, I've just copied this from a
> website.
>
> All I want to do is to kill a process which is running on several XP
> PCs - let's call it "rogueprocess.exe". If I look at Task Manager on
> the Processes tab "rogueprocess.exe" is running. And I want to kill it
> stone dead.
>
> Here's the script :
>
>
> '****************************************************************************
> Option Explicit
> Dim objWMIService, objProcess, colProcess
> Dim strComputer, strProcessKill
> strComputer = "."
> strProcessKill = "'rogueprocess.exe'"
>
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" _
> & strComputer & "\root\cimv2")
>
> Set colProcess = objWMIService.ExecQuery _
> ("Select * from Win32_Process Where Name = " & strProcessKill )
> For Each objProcess in colProcess
> objProcess.Terminate()
> Next
> '**************************************************************************
>
>
> If I run this script, it doesn't kill the process. What is wrong with
> the script?
>
> Thanks for any assistance.
>
> Stephen
Instead of running a script that is outside your field of experience, why
not use the traditional methods of killing the process?
a) Kill it from the Task Manager.
b) Kill it with this command: taskkill /f /im "RogueProcess.exe"

Note that some processes are not "killable". To test your script, use a
process that you know can be killed, e.g. "notepad.exe".


My System SpecsSystem Spec
Old 01-13-2009   #3 (permalink)
Stephen Mulholland


 
 

Re: Scripting neophyte - why does this simple script not work?

On Jan 12, 4:16*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Stephen Mulholland" <mulholla...@xxxxxx> wrote in message
>
> news:4736d787-23ea-4ba4-834f-ef3b68eb6aac@xxxxxx
>
>
>
>
>
>
>
Quote:

> > Hi all
>
Quote:

> > I know nothing at all about scripting, I've just copied this from a
> > website.
>
Quote:

> > All I want to do is to kill a process which is running on several XP
> > PCs - let's call it "rogueprocess.exe". *If I look at Task Manager on
> > the Processes tab "rogueprocess.exe" is running. And I want to kill it
> > stone dead.
>
Quote:

> > Here's the script :
>
Quote:

> > '*****************************************************************************
> > Option Explicit
> > Dim objWMIService, objProcess, colProcess
> > Dim strComputer, strProcessKill
> > strComputer = "."
> > strProcessKill = "'rogueprocess.exe'"
>
Quote:

> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" _
> > & strComputer & "\root\cimv2")
>
Quote:

> > Set colProcess = objWMIService.ExecQuery _
> > ("Select * from Win32_Process Where Name = " & strProcessKill )
> > For Each objProcess in colProcess
> > objProcess.Terminate()
> > Next
> > '**************************************************************************
>
Quote:

> > If I run this script, it doesn't kill the process. *What is wrong with
> > the script?
>
Quote:

> > Thanks for any assistance.
>
Quote:

> > Stephen
>
> Instead of running a script that is outside your field of experience, why
> not use the traditional methods of killing the process?
> a) Kill it from the Task Manager.
> b) Kill it with this command: taskkill /f /im "RogueProcess.exe"
Good points, sir, and well made.

However, when I say the rogue process is running on "several XP PCs",
you might want to read "several XP PCs" as "over 1800 XP PCs".
Oops. Long story, but basically I messed up, not to put too fine a
point on it. I rolled out a program using SMS 2003, messed up the
program's command line and now the program can't finish. I need to
kill the process invisibly, so the plan is to convert the vb script to
an exe, roll it out with SMS, let it run and finish - rogue process
killed, problem solved.

Thanks

Stephen

Quote:

>
> Note that some processes are not "killable". To test your script, use a
> process that you know can be killed, e.g. "notepad.exe".- Hide quoted text -
>
> - Show quoted text -
My System SpecsSystem Spec
Old 02-03-2009   #4 (permalink)
Python42


 
 

Re: Scripting neophyte - why does this simple script not work?

Or save a step and just use pskill (also Sysinternals free utility)


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Simple script to change filenames PowerShell
simple script to query canonical name PowerShell
Simple login mapping script doesn't run properly Network & Sharing
simple disk usage -> email script PowerShell
Sidebar corruption, IE scripting does not work Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46