Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

batch programming help reqd

Original Message
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

soma


Report Offensive Message For Removal


Response Number 1
Name: Shr0Om
Date: August 29, 2007 at 10:00:27 Pacific
Subject: batch programming help reqd
Reply: (edit)
you can list processes with tasklist in XP. I guess its avaible in w2003 as well.

Anyway.. try this

::CODE
@echo off
for /f "tokens=1-5 delims= " %%a in ('netstat -o -n ^|find "1099"') do (set PID=%%e
call :KillPID)

:KillPID
taskkill /f /PID %PID%


Report Offensive Follow Up For Removal

Response Number 2
Name: ghostdog
Date: August 29, 2007 at 19:21:59 Pacific
Subject: batch programming help reqd
Reply: (edit)
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]


Report Offensive Follow Up For Removal

Response Number 3
Name: Balkrah (by Vaughan Newton)
Date: August 31, 2007 at 10:13:27 Pacific
Subject: batch programming help reqd
Reply: (edit)
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!
)


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: batch programming help reqd

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Slow boot time

Trasnferring Documents from old HD

My k8T Neo-v usb's aren't working!

Date Modified = Date Created Time

system files on removable harddrive


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

All content ©1996-2007 Computing.Net, LLC