如何使用VB脚本检查远程服务器上的端口状态

编程入门 行业动态 更新时间:2024-10-28 13:22:44
本文介绍了如何使用VB脚本检查远程服务器上的端口状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好朋友, 任何人都可以帮我解决如何使用VB脚本检查远程服务器上的端口状态(打开和启用) 任何形式的帮助都非常值得...... Thnx -FH

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

推荐答案

嗨 i认为这段代码工作正常,但它有循环来检查我无法接受的状态,但我不能用vbs同时我认为我们不能做其他事情,因为我们无法收到vbs中的事件 ''VBScript源代码 函数CheckPort( Byval Server,Byval Port) Dim SockObject set SockObject = CreateObject(" MSWinsock.Winsock.1") SockObject.Protocol = 0''TCP 调用SockObject.Close 调用SockObject.Connect(服务器,端口) while((SockObject.State = 6)或(SockObject.State = 3))''套接字状态<>连接或连接待定 ''什么都不做 wend if(SockObject.State = 7)然后''如果socket连接 msgbox" Port OPen" msgbox"错误" elseif(SockObject.State = 0)然后''关闭 msgbox"连接被拒绝> 结束如果 调用SockObject。关闭 设置SockObject =无 结束功能 呼叫CheckPort(服务器,445) 和plz考虑到你的想法Winsock COM Class只安装了vb6组件,你不会在没有vb6组件的PC中找到它 最好的问候 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

感谢Ahmed, 逻辑正是我想要的,但我认为这不能完全解决我的问题,我需要在我的所有目标或远程服务器上安装VB6我需要运行此代码(这是我不能做的),a nyways我得到这个错误 Microsoft VBScript运行时错误:ActiveX组件无法创建对象:''MSWinsock.Winsock.1'' 有没有其他方法可以获得这些信息 Thnx一百万 FH 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

艾哈迈德, 结束了,我有这个代码,但这仅限于检查端口在本地机器上的状态,无法在远程服务器上执行 ################ CODE ################## 设置objFirewall = CreateObject(" HNetCfg.FwMgr") 设置objPolicy = objFirewall.LocalPolicy.CurrentProfile 设置colPorts = objPolicy.GloballyOpenPorts 对于colPorts中的每个objPort Wscript.Echo"端口名称:" &安培; objPort.Name Wscript.Echo" Port number:" &安培; objPort.Port Wscript.Echo" Port protocol:" &安培; objPort.Protocol Wscript.Echo" Port enabled:" &安培; objPort.Enabled 下一步 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

更多推荐

如何使用VB脚本检查远程服务器上的端口状态

本文发布于:2023-08-07 06:40:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1317545.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   端口   脚本   器上   状态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!