获取本机IP,并把本机IP写入配置文件
2022-11-14 乱云飞 标签: VB源码 获取本机IP地址 复制内容到剪切板
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set Shell = WScript.CreateObject("WScript.Shell") Set IPConfigSet = objWMIService.ExecQuery _ ("Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to LBound(IPConfig.IPAddress) strCopy= "http://" & IPConfig.IPAddress(i) & ":8000/onvif/device_service" '/// rtspip= IPConfig.IPAddress(i) '/// Call SetClipboardText(strCopy) '/// msgbox strCopy,vbOKOnly,"EZsoft" '/// Next End If Next Sub SetClipboardText(Text) '写入信息到剪切板 Dim wsh Set wsh = CreateObject("WScript.Shell") wsh.Run "mshta vbscript:ClipboardData.SetData("&chr(34)&"text"&chr(34)&"," &Chr(34)& Text &Chr(34)& ")(close)",0,True set wsh=Nothing End Sub '替换文本:把IP写入onvif.ini配置文件 20221114 set fso = createobject("scripting.filesystemobject") '读取文件 set stream = fso.opentextfile("onvif.ini",1) content = stream.readall() call stream.close() '替换字符串 content = replace(content,"wwwns.tpddns.cn",rtspip) '保存文件 set stream = fso.opentextfile("onvif.ini",2) call stream.write(content) call stream.close()本文链接:http://80c.cc/ez/597.html
发表评论: