Link to home
Start Free TrialLog in
Avatar of susan_atkins
susan_atkins

asked on

Sending Command to DOS / Automating DOS

Greetings!

I'm working on a small application that i wanted to havce automate DOS t a certain degree.  what I want is really very simple.  I want a small VB form that will open DOS and then automatically load one of four commands (depending on which button is clicked) and wait for the output.  The DOS window wouldn't even need to close itself.

I was able to bring up the DOS window but then I've been stuck with the whole passing keystrokes to it.  Lateluy I've been trying to use AppActive but every time I try to use it, I get an error.  Usually: 'Invalid Outside Procedure' / Run Time error 5.  My MSDN Help is gimped so I've been trying to find out what i can online, and from what I've seen, I still can't figure out what I'm doing wrong.

here's the code I'm trying to make work - all I want it to do, is open the DOS window (which it does) and then load in and execute to change directory command:

Private Sub Form_Load()
    Dim the_command As String
    the_command = "command.com"
    Shell the_command, vbNormalFocus
    AppActivate "the_command"
    SendKeys ("cd c:\")
End Sub
   
could someone *please* let me know where I'm going wrong on tis?  It seems like this should be a sort of easy thing and I can't understand why I'm having such a hard time with it!

Please let me know if you need any other details / clarificatin - thefamilyforever@yahoo.com

help!

sa
Avatar of twalgrave
twalgrave

AppActivate "the_command" is incorrect unless your command window has the words "the_command" in the title.  The Invalid outside procedure isn't from anything you have listed here.  You probably have a call or line of code that is not a declaration in the General Declarations section.


ASKER CERTIFIED SOLUTION
Avatar of twalgrave
twalgrave

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of susan_atkins

ASKER

Much thanks for the advice on batch files!  I knew I had to be missing *something* but the more I tried to sort it out, the more lost I got!

Much thanks again!  I wrote the commands to batch files and had them execute directly.  One side question, though - this works beautifully on 9x but when it was loaded on 2000 & NT the DOS window just pops up and then closes again.  Any ideas?

Again - HUGE THANKS!

sa
That's why I had the pause command put in the sample batch file I showed you.