mIRC Home    About    Download    Register    News    Help

Print Thread
Run dos command; return output #148084 29/04/06 09:30 PM
Joined: Jun 2005
Posts: 127
H
HAMM3R Offline OP
Vogon poet
OP Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
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!


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Re: Run dos command; return output #148085 29/04/06 10:43 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Why do you have to cd to the directory? Why don't you just run "c:\blah\blah\app.exe"?

-genius_at_work

Re: Run dos command; return output #148086 29/04/06 11:19 PM
Joined: Jun 2005
Posts: 127
H
HAMM3R Offline OP
Vogon poet
OP Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
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.


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Re: Run dos command; return output #148087 29/04/06 11:24 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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

Re: Run dos command; return output #148088 29/04/06 11:34 PM
Joined: Jun 2005
Posts: 127
H
HAMM3R Offline OP
Vogon poet
OP Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
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


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Re: Run dos command; return output #148089 29/04/06 11:41 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
If the path contains spaces, you need to surround it with "quotes".

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


-genius_at_work

Re: Run dos command; return output #148090 29/04/06 11:45 PM
Joined: Jun 2005
Posts: 127
H
HAMM3R Offline OP
Vogon poet
OP Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
//me slaps $me
Sorry, didnt mean to make such a simple thing sound so complicated. Thanks genuis!


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Re: Run dos command; return output #148091 29/04/06 11:45 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
No problem. ;P

-genius_at_work