如何用VB编写一个修改IP的软件?
如何用VB编写一个修改IP的软件?只需要一点就可以修改IP,DNS和网关或者如何做一个一点就可以运行一个BAT的,但是要求BAT内嵌在EXE里,BAT的内容不会被看见没明...
如何用VB编写一个修改IP的软件?
只需要一点就可以修改IP,DNS和网关
或者如何做一个一点就可以运行一个BAT的,但是要求BAT内嵌在EXE里,BAT的内容不会被看见
没明白,具体点成吗?我要GUI的程序啊 展开
只需要一点就可以修改IP,DNS和网关
或者如何做一个一点就可以运行一个BAT的,但是要求BAT内嵌在EXE里,BAT的内容不会被看见
没明白,具体点成吗?我要GUI的程序啊 展开
力控科技
2024-08-19 广告
2024-08-19 广告
ForceSCADA是力控科技信创产品的重要组成部分,具备完全自主知识产权,支持部署在Linux桌面版、服务器版、嵌入式等系统架构下。使用ForceSCADA可以搭建创新性高、扩展性佳、融合度强的SCADA平台,进而构建高效、智能化的监控中...
点击进入详情页
本回答由力控科技提供
展开全部
晕 你还不明白?
你画一个Textbox 名称为Text1 让用户输PAddress
Text2 输Submask Text3输Gateway
调用CfgIP text1.text,text2.text,text3,text 这时就修改IP配置了
也可以Ret&=CfgIP(Text1.text,text2.text,text3,text)
Ret返回1 设置成功 0修改失败
这个是调用WMI 脚本 不用BAT
Function CfgIP(ByVal IPaddress As String, ByVal Submask As String, ByVal Gateway As String) As Long
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array(IPaddress) ' 把你要设的IP填在这
strSubnetMask = Array(Submask) '子网掩码
strGateway = Array(Gateway) '网关
strGatewaymetric = Array(1)
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
CfgIP = 1 '设置成功返回1
Else
CfgIP = 0 '否则返回0
End If
Next
End Function
Sub CfgDNS(ByVal StrDns As String)
On Error Resume Next
Const FULL_DNS_REGISTRATION = True
Const DOMAIN_DNS_REGISTRATION = False
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard In colNetCards
objNetCard.SetDynamicDNSRegistration FULL_DNS_REGISTRATION, DOMAIN_DNS_REGISTRATION
Next
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
strHostName = "fabrikam1"
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.EnableDNS strHostName, , , arrDNSSuffixes
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard In colNetCards
arrDNSServers = Array(StrDns) '主DSN和备用DNS StrDns="xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx"
objNetCard.SetDNSServerSearchOrder (arrDNSServers)
Next
End Sub
你画一个Textbox 名称为Text1 让用户输PAddress
Text2 输Submask Text3输Gateway
调用CfgIP text1.text,text2.text,text3,text 这时就修改IP配置了
也可以Ret&=CfgIP(Text1.text,text2.text,text3,text)
Ret返回1 设置成功 0修改失败
这个是调用WMI 脚本 不用BAT
Function CfgIP(ByVal IPaddress As String, ByVal Submask As String, ByVal Gateway As String) As Long
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strIPAddress = Array(IPaddress) ' 把你要设的IP填在这
strSubnetMask = Array(Submask) '子网掩码
strGateway = Array(Gateway) '网关
strGatewaymetric = Array(1)
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
CfgIP = 1 '设置成功返回1
Else
CfgIP = 0 '否则返回0
End If
Next
End Function
Sub CfgDNS(ByVal StrDns As String)
On Error Resume Next
Const FULL_DNS_REGISTRATION = True
Const DOMAIN_DNS_REGISTRATION = False
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard In colNetCards
objNetCard.SetDynamicDNSRegistration FULL_DNS_REGISTRATION, DOMAIN_DNS_REGISTRATION
Next
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
strHostName = "fabrikam1"
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.EnableDNS strHostName, , , arrDNSSuffixes
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objNetCard In colNetCards
arrDNSServers = Array(StrDns) '主DSN和备用DNS StrDns="xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx"
objNetCard.SetDNSServerSearchOrder (arrDNSServers)
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询