PDA

View Full Version : execute netsh with "Run as administrator" in VBA



jaywang2000
11-15-2018, 11:45 PM
How can I run the following code with "Run as administrator"? Thanks!

Dim oExec
Dim oShell: Set oShell = CreateObject("WScript.Shell")
' Dim command As String
' Set objShell = CreateObject("Shell.Application")
'Set WshShell = WScript.CreateObject("WScript.Shell")


oShell.CurrentDirectory = "D:\ARSL"
'
'netsh interface ipv4 set address "local network" static 192.168.1.7 255.255.255.0 192.168.1.1 1
'
Set oExec = oShell.Exec("netsh interface ipv4 set address " & Chr(34) & "local network" & Chr(34) & "static 192.168.1.2 255.255.255.0 192.168.1.1 1")