mIRC Homepage

Run dos command; return output

Posted By: HAMM3R

Run dos command; return output - 29/04/06 09:30 PM

Hey. I need to be able to run a program in dos, and return the output. For example, I open a dos prompt. I type in "cd C:\Program Files\App" then "app.exe". This would run C:\Program Files\App\app.exe". Then app.exe outputs "app.exe opened successfully". I tried working from an alias called _ping. It uses dos to ping a host and return the resolve time. However, i can only run one command with that code. And i have to be able to cd to the directory, then run the app (requires 2 commands). So any idea how to do this? I think i could use a .bat script, but i dont know how to return the output. Thanks in advance!
Posted By: genius_at_work

Re: Run dos command; return output - 29/04/06 10:43 PM

Why do you have to cd to the directory? Why don't you just run "c:\blah\blah\app.exe"?

-genius_at_work
Posted By: HAMM3R

Re: Run dos command; return output - 29/04/06 11:19 PM

It has to be run in dos, because the output is in dos. If i use mIRC's run command and run app.exe a dos window will pop up, but then i'll have no way of reading the output in that window.
Posted By: genius_at_work

Re: Run dos command; return output - 29/04/06 11:24 PM

What I mean is, you said you were using an existing ping script. You should be able to call the c:\blah\blah\app.exe command instead of the ping.exe command. Running applications doesn't require that you "cd" to the containing directory. cd is mainly meant for human interaction.

For example, to test your app.exe, you could open a command prompt window, remain in whatever directory it happens to open in, and type c:\blah\blah\app.exe (use the correct path of course). It should run the app normally.

-genius_at_work
Posted By: HAMM3R

Re: Run dos command; return output - 29/04/06 11:34 PM

Well...
Quote:
C:\Documents and Settings\HAMM3R>C:\Program Files\App\app.exe
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.


Am i missing something?
Command
Posted By: genius_at_work

Re: Run dos command; return output - 29/04/06 11:41 PM

If the path contains spaces, you need to surround it with "quotes".

C:\>"c:\blah blah\blah\app.exe"


-genius_at_work
Posted By: HAMM3R

Re: Run dos command; return output - 29/04/06 11:45 PM

//me slaps $me
Sorry, didnt mean to make such a simple thing sound so complicated. Thanks genuis!
Posted By: genius_at_work

Re: Run dos command; return output - 29/04/06 11:45 PM

No problem. ;P

-genius_at_work
© 2022 mIRC Discussion Forums