I'm trying to use command prompt as an admin using vb.net and I'm opening it by using runas in the default cmd.exe file. I want to then run commands through the newly opened command prompt window running as the domain admin using vb.net. How do I go about doing this?
This is the method that I'm using:
Public Sub runCmd(ByVal pass As String, ByVal command As String, ByVal arguments As String, ByVal permanent As Boolean)
Dim p As Process = New Process()
Dim pi As ProcessStartInfo = New ProcessStartInfo()
pi.Arguments = " "+ If(permanent = True, "/K", "/C") + " " + command + " " + arguments
pi.FileName = "cmd.exe"
p.StartInfo = pi
p.Start()
End Sub
This is the call that opens cmd:
runCmd(strPass, "runas", "/user:<domain>\" + strUser + " cmd", False)