Mohsin Malik
Mohsin Malik

Reputation: 53

How do I scan for open ports on a server using vbscript?

I am trying to write a script which will take in a server name and a port and checks if that port is open. Not sure how to do this is VBS. I've scoured the internet and have found nothing so far.

Upvotes: 2

Views: 1307

Answers (1)

Ali
Ali

Reputation: 3469

First Download PortQry Command Line Port Scanner Version 2.0 from Microsoft.com and extract it..

Then define some variable as below:

strPortQry = "C:\PortQryV2\PortQry.exe"
strServer = "127.0.0.1"
intPortNo = 8080

And Use the PortQry utility to find a port listen or open with this code:

PortQry.exe -n 127.0.0.1 -e 80

Something like :

objShell.Exec(objFSO.GetFile(strPortQry).ShortPath & " -n " & strServer & " -e " &  intPortNo)

You can loop on port and chech any port you want. For more information please check Microsoft help for PortQry utility and check This Site may be helpfull.

Upvotes: 1

Related Questions