Automate Command Prompt Window (CMD) and doing many commands at a time
So I'm using this http://www.vbforums.com/showthread.p...tion-2003-2005 but I want to be able to issue a lot of commands not just a single command also I want them to be done automatically I need to do like 5 different commands without the commands restarting. I tried having it do a button click after each one but it seems to be clearing the commands that where placed before so when I do this
Code:
txtCommand.Text = "cd c:\"
Button3_Click(Button3, EventArgs.Empty)
and then try to run an application from that location it fails because somehow it's resetting the CMD before it lets me issue my 2nd command.
anyone here that could help me get this to work for multiple commands without resetting?
thanks in advance also let me know if you think this is impossible.
Re: Automate Command Prompt Window (CMD) and doing many commands at a time
What do you mean by "resetting"?
Re: Automate Command Prompt Window (CMD) and doing many commands at a time
meaning that the calls between the commands aren't persisting... so if I do a "cd \cmd" ... it does... but the window (the hidden cmd one) doesn't stick around, so if I then try to run a file in that folder, it's not there because the cd wasn't persisted... the next command gets run in a new window...
If you need to run multiple commands, and you know what they are... put them into a .bat file... and then run that.
-tg
Re: Automate Command Prompt Window (CMD) and doing many commands at a time
Ahh, I wasn't thinking.. And the reason is because the code there is just using the Process class alone. Why not p/Invoke AllocConsole and use that for the entire session? There's shouldn't be a reason to run a batch file. Hiding that allocated console wouldn't be difficult at all either with the p/Invoke'd ShowWindow function.