How to check the Ports Status on a remote server using VB Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AHMEDYO
    New Member
    • Nov 2007
    • 112

    #16
    answer is No..

    Bet Regards

    Comment

    • AHMEDYO
      New Member
      • Nov 2007
      • 112

      #17
      HI..

      but i could be wrong , i think that answer is no, because the listining ports is open by the running process at runtime and no process is registry each port in registry, all i was know thats OS have TCP table and UDP table and all of these tables stored in memory not in registry, and you can get it using API call, but from VBscript i dont know where i can get it from, but i think may be there is way to do that from Winmgmts: or RPC i dont know exactly, i am not experienced with them, and i think may be you could get what ports OS services provide from registry as Microsoft-Ds port = "445" from registry Key for example

      Code:
      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters
      TransportBindname="[url="file://\\Device"]\Device[/url]\"
      transportBindna me="\Device\" mean that Netbt service will listen at port 445, but i think there is no way to get all listining ports

      Thats what i was think

      Best Regards

      Comment

      • mdfidahussain
        New Member
        • Oct 2007
        • 40

        #18
        Ahmed,

        I have tried with the script you have given, but it is not giving me any result (I can only see a blank out put) nothing is getting retrieved

        thnx

        Comment

        • mdfidahussain
          New Member
          • Oct 2007
          • 40

          #19
          I have copied "MSWINSCK.o cx" to C:\WINNT|System 32 and also registered it, checked everything is fine, looks like the code needs to be modified, can you please take a loook at your code once again and send me again.

          thnx a million for ur patience and support, appreciate you... :)

          Comment

          • mdfidahussain
            New Member
            • Oct 2007
            • 40

            #20
            Ahmed...... I got it this time

            slightly modifed your script, removed While and added some other logic...I got it this time........... . :)

            GR8 THANKS AHMED.......rea lly appreciate your srupport

            Call CheckPort(srv_n ame,77)

            Dim SockObject
            Function CheckPort(Byval Server,Byval Port)
            set SockObject=Crea teObject("MSWin sock.Winsock.1" )
            SockObject.Prot ocol=0 ' TCP
            SockObject.Clos e
            SockObject.Conn ect Server,port
            Wscript.Sleep 50
            if(SockObject.S tate=6) then ' if sockect is attempting to connect i.e
            WScript.echo "Invalid Port"
            elseif(SockObje ct.State=7) then ' if socket connected
            WScript.echo "Port Open"
            elseif(SockObje ct.State=9)then ' If Error
            WScript.echo "error"
            elseif(SockObje ct.State=0)then 'Closed
            WScript.echo "connection refused"
            end if
            call SockObject.Clos e
            set SockObject=noth ing
            End Function

            Comment

            • AHMEDYO
              New Member
              • Nov 2007
              • 112

              #21
              HI...

              Good work Man, its seem pretty nice now :)

              Kind Regards

              Comment

              Working...