Jump to content

Java - close cmd prompt opened by exec

oliverjrose99

Hi

 

In order to start a SQL server I need to run a .bat file but when I do it in java it leaves the cmd prompt open. I found "Runtime.getRuntime().exec("taskkill /f /im cmd.exe");" online but I don't feel that this is a safe way to close it. Is there a proper way of closing the window?

 

Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

If my previous answer did not work, try this:

 

Runtime.exec("cmd /c start /MIN ...")

The /MIN parameter will prevent windows from appearing in the first place. So you don't have to close it :)

 

Also, did you know there is this website called google? You can type any question in that website and you can probably find an answer. Don't be so lazy!

Link to comment
Share on other sites

Link to post
Share on other sites

Also, did you know there is this website called google? You can type any question in that website and you can probably find an answer. Don't be so lazy!

And where do you think Google search results wind up? Right back here. If Linus had his way right now you would be banned however I'm feeling nice.

Link to comment
Share on other sites

Link to post
Share on other sites

Also, did you know there is this website called google? You can type any question in that website and you can probably find an answer. Don't be so lazy!

Forums exist for a reason, if people didn't have questions we wouldn't be here.

Link to comment
Share on other sites

Link to post
Share on other sites

And where do you think Google search results wind up? Right back here. If Linus had his way right now you would be banned however I'm feeling nice.

Idiot. This question is not unique. This has been answered many time on many other forums such as stackoverflow. There are people out there who don't want to put any effort.

 

Feel free to ban me though, I will just create a new account. Even if you use IP ban, I will use hotspotshield (which used to be a LTT sponsor:) ) to create a new account.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×