locked
batch file RRS feed

  • Question

  • i need to test if the port is in use i found this but i cant get it to work:

    netstat -an | findstr /RC:":%port% .*LISTENING" && ECHO Port is in use && EXIT 1

    %port% is a var with the port number that user as typed previously when i ask wich port he wants to run the program.

    if port is already in use must show an error and say to enter another port else should continue

    • Moved by Helen Zhou Tuesday, November 1, 2011 9:20 AM (From:Windows Forms General)
    Sunday, October 30, 2011 10:12 PM

Answers

All replies

  • Hi hugo,

    This question has few relation with Windows Forms issue, I'm moving it to Off topic forum to see if someone can help. But before that, maybe this blog about Command-line view of ports in use would be some of help.

    Best wishes,


    Helen Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 1, 2011 9:19 AM
  • ok but your link doesnt help me tomuch because it is to make the commands on a cmd and i need to make it on a batch file burt i doesnt know how to run that command on a batch file.

    why my frist post is reported as abusive?

    Tuesday, November 1, 2011 12:54 PM
  • This thread was moved out of Win Form. Is there another forum that supports batch scripting? What about the Scripting Guys forum?
    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Thursday, November 3, 2011 5:58 AM