Link to home
Start Free TrialLog in
Avatar of itbabe
itbabe

asked on

Vbscript : I need to kill a process at a certain path using vbs. (Java.exe that is located in a certain folder)

please help
Avatar of Ashish Patel
Ashish Patel
Flag of India image

if you are using win xp then use shell function and fire "tskill java.exe"
Avatar of itbabe
itbabe

ASKER

I have 2 java.exe's running and only want to kill the one at a particular path.
you cant kill at particular path, but you can either kill all process by name or either by process id (PID) using same tskill command. For more help on that go to command prompt and type tskill and enter key for help.
Avatar of merowinger
as asvforce said, u cant kill a process on a specified path, but the following code shows how to kill a task:



Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'calc.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
ASKER CERTIFIED SOLUTION
Avatar of itbabe
itbabe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
nice idea :)
Closed, 500 points refunded.
modus_operandi
EE Moderator