windows获取ip
环境:windows、vbs
1、新建txt拷贝内容到文件,修改文件后缀名vbs,双击即可执行
Set WshShell = WScript.CreateObject("WScript.Shell") Set oExec = WshShell.Exec("ipconfig.exe") Set oStdOut = oExec.StdOut ip = "" Do Until oStdOut.AtEndOfStream strLine = oStdOut.ReadLine If InStr(strLine, "IPv4 地址") > 0 Then ip = Mid(strLine, InStr(strLine, ":") + 2) Exit Do End If Loop If ip = "" Then MsgBox "获取本地连接IP地址失败!", vbExclamation, "错误" WScript.Quit Else MsgBox ip, vbExclamation, "本地连接IP地址!" End If WScript.Quit
做一个决定,并不难,难的是付诸行动,并且坚持到底。