This is my code trying to run cmd.exe with admin priviligies. However, I get the request operation requires elevation. if I run cmd.exe with "Run as Admin" through my windows, it works, however, through vb, it doesn't. This is my code.
Thanks.
vb Code:
Try Dim process As New Process() process.StartInfo.FileName = "cmd.exe " process.StartInfo.Verb = "runas" process.StartInfo.UseShellExecute = False process.StartInfo.RedirectStandardInput = True process.StartInfo.RedirectStandardOutput = True process.StartInfo.RedirectStandardError = True process.StartInfo.CreateNoWindow = True process.Start() process.StandardInput.WriteLine("route add 8.31.99.141 mask 255.255.255.255 " & cmdorder) process.StandardInput.WriteLine("exit") Dim input As String = process.StandardOutput.ReadToEnd process.Close() Dim regex As Regex = New Regex("(ok)+", RegexOptions.IgnoreCase) ' wa requested ' txtLog.AppendText(input) Return regex.IsMatch(input)
Thanks.