• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

KIll or Eliminate Dos prompt after Process execution.

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
i am wokring on execution on execution of Dos Commands using java.But i am facing problem. Whenever i execute a command using Process. RunTime.exec(Copy/move etc) , the black dos prompt pops up and remains there and the program keeps hanging untill i close the Command prompt window.
Please write me the command/code to eliminate that window in the end or hide that window so that my program should execute successfully without hanging in the middle.
Thanks .
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at the options you can set on cmd.exe??

If I remember correct then you need to set /k (I'm not using Windows any more, so I can't test it for you)
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks !! Well i've used "taskkill /m cmd.exe" command to close all command prompts.
 
Sheriff
Posts: 22850
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Rene meant using a flag for cmd.exe, for instance "cmd.exe /c command". You may now be closing command windows that are not started by your application!

Rene: /k is the opposite of /c. /c terminates afterwards, /k "remains" (quoted from cmd /?).
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, you are right - I knew that it was one of them
 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry rene and rob.. i still didn't get what you are talking about ..??
The Taskkill i talked about earlier kills all the command prompts open , it may prove dangerous for my code as i want to close only the
command prompt related to the command i've executed. Suppose if there are already some batchfile running in my system and i called
a new process through java to execute XCOPY command , it will open a new DOS prompt and execute the command,now i want to close
that command prompt only related to my command not the other batch file dos prompt which is already running. Help me if there is any
command to exit from a particular Dos prompt.
thanks .
 
Rene Larsen
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An example could be...

In a DOS prompt you write:

this code should open a new DOS prompt - show the dir contents and then close the prompt again (you probably don't see the output)

If you instead uses the /k flag - the new DOS prompt will stay open.

 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am already using /c in command.. but this is not working. The Dos prompt keeps the control adn doesn't give back to Java program untill closed manually .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic