|
-
May 13th, 2013, 04:12 PM
#1
Thread Starter
Hyperactive Member
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.
-
May 13th, 2013, 04:43 PM
#2
Re: Automate Command Prompt Window (CMD) and doing many commands at a time
What do you mean by "resetting"?
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
-
May 13th, 2013, 05:19 PM
#3
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
-
May 13th, 2013, 05:21 PM
#4
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.
Last edited by AceInfinity; May 13th, 2013 at 05:25 PM.
<<<------------
.NET Programming (2012 - 2018)
®Crestron - DMC-T Certified Programmer | Software Developer <<<------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|