Dim pi As New System.Diagnostics.ProcessStartInfo()
pi.FileName=(ipchangepath)
pi.RedirectStandardError = True
pi.RedirectStandardOutput = True
pi.Verb = "runas"
pi.CreateNoWindow = true
pi.UseShellExecute =False
Dim p As process=Process.Start(pi)
My.Computer.FileSystem.WriteAllText(errorpath, p.StandardOutput.ReadToEnd(), True)
My.Computer.FileSystem.WriteAllText(errorpath, p.StandardError.ReadToEnd(), True)
我正在尝试从我的vb.net应用程序运行批处理文件,但它需要管理员权限才能运行。
我尝试了上面的代码,但错误显示它需要以管理员身份运行
C:\Users\JONAH\Documents\SharpDevelop Projects\LinkIt\LinkIt\bin\Debug>netsh interface ip set address name=Wi-Fi source=static addr=10.10.118.161 mask=255.255.254.0 gateway=10.10.116.25 gwmetric=0
The requested operation requires elevation (Run as administrator).
C:\Users\JONAH\Documents\SharpDevelop Projects\LinkIt\LinkIt\bin\Debug>netsh interface ip set dns "Wi-Fi" static 10.10.116.5
The requested operation requires elevation (Run as administrator).
C:\Users\JONAH\Documents\SharpDevelop Projects\LinkIt\LinkIt\bin\Debug>netsh interface ip add dns "Wi-Fi" 202.200.100.95 index=2
The requested operation requires elevation (Run as administrator).