I am trying to run the below command from command prompt using vbscript and then capture the result in a text file.
netstat -an -p tcp | find /c ":80" > C:\Users\Swarnabha\Desktop\test.txt
I have written the below code but it is not working... Help me here plz!
Dim filepath
filepath= "C:\Users\Swarnabha\Desktop\test.txt"
Dim connstr
Dim portno
portno = ":80"
connstr = "cmd netstat -an -p tcp | find /c "& portno &" > "& filepath
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run connstr
Set oShell = Nothing
WScript.Quit