Hello everyone, I am writing a program and need some help with what should be the easiest part......
Basically, my program opens up CMD as an administrator, but after it does that I want it to run a command, I tried using sendkeys but that didnt work at all. the CMD window does appear to be the active window (it is in front of all the other windows, and if I type on the keyboard the text is displayed there) but the sendkeys doesnt actually send any keys. Can anyone give me some help please?
TL😀R
Want CMD to open as administrator then run command. Open as admin works, but I cant get it to run a command after it opens.
Basically, my program opens up CMD as an administrator, but after it does that I want it to run a command, I tried using sendkeys but that didnt work at all. the CMD window does appear to be the active window (it is in front of all the other windows, and if I type on the keyboard the text is displayed there) but the sendkeys doesnt actually send any keys. Can anyone give me some help please?
TL😀R
Want CMD to open as administrator then run command. Open as admin works, but I cant get it to run a command after it opens.
Code:
Dim process As New Process()
process.StartInfo.FileName = "cmd.exe"
process.StartInfo.Verb = "runas"
process.StartInfo.UseShellExecute = True
process.Start()
System.Threading.Thread.Sleep(3000)
SendKeys.Send("ipconfig /all")
SendKeys.Send("{ENTER}")