Name: soma.sen Date: August 29, 2007 at 07:12:49 Pacific Subject: batch programming help reqd OS: win2003 CPU/Ram: 1gb Model/Manufacturer: intel
Comment:
Hi i am new to batch programming I just need to: 1. start Windows Task Manager inside my batch file 2. list all active processes 3. discover the wanted-processes (check by doing netstat -ano is port no 1099 being used if yes the get the PID and find the name of the process) 4. kill it
it seems you know what's the process name by using netstat..here's a vbscript to kill process. Its just an example. Don't use svchost.exe in your case [code] strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'svchost.exe'")
For Each objProcess in colProcessList objProcess.Terminate() Next [/code]
Scr0Om: If you used your batch script the 'find' command could output a line with "1099" as the PID, instead of the port. Its unlikely, but anyway to fix this you could use
@echo off setlocal EnableDelayedExpansion for /f "tokens=1-5 delims= " %%a in ('netstat -on ^|find ":1099"') do ( set PID=%%e taskkill /f /PID !PID! )
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE