Hello Friends,
Can any body help me out in "how to check the Ports Status (opened & enabled) on a remote server using VB Script
Any sort of help is highly appreciable.....
Thnx
-FH
20 47030
hi
i think this code work well but it have loop to check for state that i cant accept but im not good in vbs and in same time i think we cant do other thing because we cant receve events in vbs
' VBScript source code
Function CheckPort(Byval Server,Byval Port)
Dim SockObject
set SockObject=CreateObject("MSWinsock.Winsock.1")
SockObject.Protocol=0 ' TCP
Call SockObject.Close
Call SockObject.Connect (Server,Port)
while ((SockObject.State=6) or (SockObject.State=3)) 'socket state <> connecting or connection pending
'do nothing
wend
if(SockObject.State=7) then ' if socket connected
msgbox "Port OPen"
elseif(SockObject.State=9)then' If Error
msgbox "error"
elseif(SockObject.State=0)then 'Closed
msgbox "connection refused"
end if
call SockObject.Close
set SockObject=nothing
End Function
Call CheckPort("Server",445)
and plz take in ur mind Winsock COM Class is only installed with vb6 component and u will not find it in PC that not have vb6 components
Best Regards
Thanks Ahmed,
The logic is exactly what Iwant but I think this will not completely solve my problem, I need to install VB6 on all my target or remote servers on which I need to run this code (and this I cannot do), anyways I am getting this errror
Microsoft VBScript runtime error: ActiveX component can't create object: 'MSWinsock.Winsock.1'
is there any other way to get this info
Thnx a million
FH
Ahmed,
More over, I have this code, but this is limited to check the ports' status on local machine, cannot be executed on a remote server
################ CODE ##################
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
Set colPorts = objPolicy.GloballyOpenPorts
For Each objPort in colPorts
Wscript.Echo "Port name: " & objPort.Name
Wscript.Echo "Port number: " & objPort.Port
Wscript.Echo "Port protocol: " & objPort.Protocol
Wscript.Echo "Port enabled: " & objPort.Enabled
Next
Ahmed,
More over, I have this code, but this is limited to check the ports' status on local machine, cannot be executed on a remote server
################ CODE ##################
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
Set colPorts = objPolicy.GloballyOpenPorts
For Each objPort in colPorts
Wscript.Echo "Port name: " & objPort.Name
Wscript.Echo "Port number: " & objPort.Port
Wscript.Echo "Port protocol: " & objPort.Protocol
Wscript.Echo "Port enabled: " & objPort.Enabled
Next
yas man u wanna enumerate Open Ports but i was give u port scanner , sorry :D , because u dont wanna external component and u wanna to get ports from remote server , i think and not sure may be using WMI winmgmts Class , but it have heavy number of classes and i must take a look, and i will response
Thanks Ahmed,
The logic is exactly what Iwant but I think this will not completely solve my problem, I need to install VB6 on all my target or remote servers on which I need to run this code (and this I cannot do), anyways I am getting this errror
Microsoft VBScript runtime error: ActiveX component can't create object: 'MSWinsock.Winsock.1'
is there any other way to get this info
Thnx a million
FH
:D as i said u dont have MSWinsockLib in ur machine , u must install it
I installed it, but still getting the same error, any help using Win32_ classes or any other you know from which I can get the ports info using VBScript
I installed it, but still getting the same error, any help using Win32_ classes or any other you know from which I can get the ports info using VBScript
which file you installed?, and how u install it????
the file name is MSWINSCK.OCX
after you copy it you must registry it
by the way, try to change the socket number or remove it in the current line - set SockObject=CreateObject("MSWinsock.Winsock.1")
or use "Regedit" search the registry about ".Winsock" to see what version you install
and i will search about Winmgmts Win32_Classes and i will reply
GOOD LUCK
Thnks Ahmed I have searched almost all of the Win32_ classes, couldn't find any helpful, s stated earlier the below is only gathering the ports info on the local pc, not sure where to give the remote server name as input in it
Any idea how to run this code on a remote server?
################ CODE ##################
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
Set colPorts = objPolicy.GloballyOpenPorts
For Each objPort in colPorts
Wscript.Echo "Port name: " & objPort.Name
Wscript.Echo "Port number: " & objPort.Port
Wscript.Echo "Port protocol: " & objPort.Protocol
Wscript.Echo "Port enabled: " & objPort.Enabled
Next
##########################################
I am just searching for an option that could be available for "LocalPolicy" in the "Set objPolicy = objFirewall.LocalPolicy.CurrentProfile", tried alot but of no luck................any sort of help will be highly appreciable.....
Regards
Thanks a million for ur patience......Awaiting for ur valuable reply...:)
Thanks a million for ur patience......Awaiting for ur valuable reply...:)
Many Thanx man, i am trying, searching and thinking, i think i will got it
:D
Regards...
Any luck Ahmed.... ???
thnx
Awaiting for ur valuable reply Ahmed........
thnx a million
Hey..
i wanna ask a question because i think there is no way to check about open ports except scanning as i was post to you the first script
the question is , this script will run within domain??, have active directory??, if so, i think we have two ways to do that.
first distribute MSWinsock Library in your server then we can use it AS DCOM from any PC within domain
second,we can copy MSWinsock.ocx to \\Domain.Com\Sysvol shared (and almost all users have permission to access this folder to access policy) folder and then improve the first script to check if Winsock found in current machine or not , if not it will copy the MSWinsock .OCX file to system32 folder and registry it and then we can use Winsock Object
Waiting your reply
Best Regards.
We dont have an AD, is there any way from which we can get ports info from server's registry entry??
thnx
answer is No..
Bet Regards
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 - HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT\Parameters
-
TransportBindname="\Device\"
-
transportBindname="\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
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
I have copied "MSWINSCK.ocx" to C:\WINNT|System32 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... :)
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.......really appreciate your srupport
Call CheckPort(srv_name,77)
Dim SockObject
Function CheckPort(Byval Server,Byval Port)
set SockObject=CreateObject("MSWinsock.Winsock.1")
SockObject.Protocol=0 ' TCP
SockObject.Close
SockObject.Connect Server,port
Wscript.Sleep 50
if(SockObject.State=6) then ' if sockect is attempting to connect i.e
WScript.echo "Invalid Port"
elseif(SockObject.State=7) then ' if socket connected
WScript.echo "Port Open"
elseif(SockObject.State=9)then' If Error
WScript.echo "error"
elseif(SockObject.State=0)then 'Closed
WScript.echo "connection refused"
end if
call SockObject.Close
set SockObject=nothing
End Function
HI...
Good work Man, its seem pretty nice now :)
Kind Regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: iqbal |
last post by:
Hi all,
We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the...
|
by: banz |
last post by:
Hello
I have a problem to resolve: I wrote a Perlscript which caches data from a
server (local on my machine) I would like to have a other connection to a
remote server but I don't know how to...
|
by: gallaczmit |
last post by:
Will this code give me a true view of a computer's status? All I am
looking for is to see if the computer is reachable or not.
My end goal is to get a list of IP addresses from a MS SQL Server,...
|
by: pratcp |
last post by:
I have a remote server (a shared hosting webserver) where I have few
users ftp some flat files. I need to access these files using a windows
app/windows service written using c# and run it on a...
|
by: Computer geek |
last post by:
I am a beginner programmer and would like a little help with a piece
of code. Does anyone know how write code that will check the status of
a service running on a remote server? Or is it even...
|
by: mdfidahussain |
last post by:
Hi Friends,
Anyone help me out in getting Ports' status information from the Registry Key? if there is no possibility of getting this info from Registry entry, is there any other way from whic I...
|
by: kriz4321 |
last post by:
Hi All,
I need to connect to a remote server using perl. The server is SSH enabled and I find it difficult to Install Net::SSH::Perl as it has many modules as prereq.
I have Installed NET:Telnet...
|
by: kottiPrasad |
last post by:
Hello ,
I have mailboxes in the exchange server and i need to copy the mailboxes data from the exchange server and place it to the other exchange server using c#.Is it possible to access the...
|
by: laxmimanasa |
last post by:
Hi all,
I am working with python. I have to write script to open putty and connect to remote server and display the disks details.
I used the commans os.popen3("path of putty") to connect to putty...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |