|
1.
Shell "cmd.exe /k ipconfig.exe", vbNormalFocus
---
2.
' 請設定引用項目Windows Script Host Object Model
Sub ipconfigAll()
Dim wscr As WshShell
Set wscr = New WshShell
If InStr(1, Application.OperatingSystem, "NT") > 0 Then
MsgBox wscr.Exec("ipconfig").StdOut.ReadAll ' NT
Else
MsgBox wscr.Exec("winipcfg").StdOut.ReadAll ' Win 9 - x
End If
End Sub
---
3.
Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim I As Integer
strComputer = "."
Set objWMI = GetObject("winmgmts://" & strComputer & "oot/cimv2")
Set colIP = objWMI.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNull(IP.IPAddress) Then
For I = LBound(IP.IPAddress) To UBound(IP.IPAddress)
MsgBox IP.IPAddress(I), vbInformation, IP.Description(I)
Next
End If
Next
End Sub
|
|