Results 1 to 4 of 4

Thread: Automate Command Prompt Window (CMD) and doing many commands at a time

  1. #1

    Thread Starter
    Hyperactive Member Vexslasher's Avatar
    Join Date
    Feb 2010
    Posts
    429

    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.

  2. #2
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    Re: Automate Command Prompt Window (CMD) and doing many commands at a time

    What do you mean by "resetting"?
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .NET Programming (2012 - 2018)
    ®Crestron - DMC-T Certified Programmer | Software Developer
    <<<------------

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    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.
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .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
  •  



Click Here to Expand Forum to Full Width