Computer Hope

Microsoft => Microsoft DOS => Topic started by: crest.boy on December 20, 2010, 11:24:13 PM

Title: ask for help to crate batch script to judge which program occupy specified port
Post by: crest.boy on December 20, 2010, 11:24:13 PM
Hi friends,

I'd like to get a batch script to accept one argument indicating port number and the output of the script is the program name which currently occupies the port. Just like:

input: demo.bat 80
output: firefox.exe
question: what scripts should be implemented in demo.bat?

Could you please do me a favor?

Thanks in advance!!
Title: Ask for help to create batch script to judge which program occupy specified port
Post by: terrylangley on December 23, 2010, 06:14:34 PM
http://www.petefreitag.com/item/77.cfm
Title: Re: ask for help to crate batch script to judge which program occupy specified port
Post by: Salmon Trout on December 24, 2010, 01:05:20 AM
And that helps how exactly, terrylangley?
Title: Re: ask for help to crate batch script to judge which program occupy specified port
Post by: DaveLembke on December 29, 2010, 03:32:10 PM
I'd download and use http://www.mcafee.com/us/downloads/free-tools/fport.aspx (http://www.mcafee.com/us/downloads/free-tools/fport.aspx) FPORT with /a switch (/a sort by application) and pass the Firefox.exe application switch to it, you then can use batch to use the output  and parse it as needed to perform other tasks or just >>write_output_to_file.txt in which other programs can read in the txt file and run routines that batch may not be able to perform.

Great link on parsing with batches: http://ss64.com/nt/for_f.html (http://ss64.com/nt/for_f.html)