• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

External dos command

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi java jedis, I've got a little problem with launching external applications (in windows) that even after looking around for explanations didn't get solved...
When I run something like:
try
{Runtime rt = Runtime.getRuntime();
Process pc = rt.exec("C:/Windows/command.com /c dir /p");
}
catch(IOException ioe){}
it seems I'm not able to run dos mode applications or dos commands. Everything remains as is with no changes, but if I try running write.exe or the like everything is ok. Any ideas ?
Thanks !
Andy
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try using something like this:
Runtime.getRuntime().exec("cmd /K start run.bat");
Runtime.getRuntime().exec("cmd /K del run.bat");
Only the older versions of Windows still use "command".
Also here is a good article about exec http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
Andy Sabb
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ehm, yep thanks for your help, that article is really uhm (long ? ) neat.
But trying "cmd /k" doesn't work and I still (maybe I'm just a bit dumb) can't make it work as I intended to...
I'm sorry to bother you more, but I'm writing a Java MAME Frontend (bad idea ? found that too late ). Everything is perfect and in place (and I even like it), apart from a tiny inconvenient... I can't run the emulator ! . The command string would be "c:/games/mame/mame.exe " + romname, but when I call it, it just hangs ! Thanks anyway if you have time to reply...
Cheers
Andy
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are just trying to start an executable, you do not need cmd or command. You just name the executable and the input parameter.
Your input choices include feeding in ONE stringl, or setting up some String arrays and feeding that it.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cindy,

I've tried it myself... it works fine with programs that are made to run in windows, but programs that are made to run in DOS just hang...

For example, if you try running "ipconfig.exe" or "NetHack.exe" or other things made to run at the DOS prompt instead of textpad, notepad, or other programs made to run in a new window...

Puzzling...

-Nate
 
Cindy Glass
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm. . . . Must have something to do with the fact that we are starting a new process instead of just using the process that is controlling the dos window.
I'll have to poke into this.
reply
    Bookmark Topic Watch Topic
  • New Topic