שתף באמצעות


Send keys to command prompt

Question

Monday, May 25, 2009 2:07 AM

I have an application that will open a command prompt (cmd.exe), and then types "ipconfig/renew". How do I send the enter key, to execute the command?

So far i have:

Process.Start("cmd.exe")
My.Computer.Keyboard.SendKeys("ipconfig/renew")
My.Computer.Keyboard.SendKeys(Keys.Enter)

When I use "Keys.Enter", it sends "13". How do I make it press Enter, not put "13" on the command line?

All replies (3)

Monday, May 25, 2009 2:17 AM ✅Answered

Hi,

try to use like this.

My.Computer.Keyboard.SendKeys("{enter}")

this may help!!


Monday, May 25, 2009 2:14 AM

Try to use,

 System.Windows.Forms.SendKeys.SendWait("{ENTER}")

Best Regards,
Lucas Luo


Monday, May 25, 2009 2:33 AM

Thank you so much for that. I'm only 13 and trying to figure out the VB lingo, that was the last thing I needed to complete my application! Thank You!