This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to prevent a MS DOS window popping up when I run cmd.exe from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to prevent a MS DOS window popping up when I run cmd.exe from java" Watch "How to prevent a MS DOS window popping up when I run cmd.exe from java" New topic
Author

How to prevent a MS DOS window popping up when I run cmd.exe from java

Rajagopal Manohar
Ranch Hand

Joined: Nov 26, 2004
Posts: 183
Hi All,

I have a GUI application which has to do a lot of IO. This was making it too slow. To improve the performance I tried using xcopy to do the copying



It worked much faster but now I am having a new problem a MS Dos window keeps popping out every time I run the xcopy which is a real eye sore.

googling around I get a feel that the best I can do it to minimise it.

But before giving up I wanted to ask the ranchers is there and way a simple trick, workaround where I can continue to use xcopy and not have the cmd window popping up.

any help in this will be greatly appreciated


-Rajagopal
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18545
    
  40

Instead of running cmd.exe to run xcopy, have you tried running xcopy.exe directly?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rajagopal Manohar
Ranch Hand

Joined: Nov 26, 2004
Posts: 183
Hi Henry,

Thanks for the reply.

I tried


but it did not work.

is there any other way workaround by which I can keep those windows from popping up.

Thanks,
Rajagopal
Hemal Pandya
Greenhorn

Joined: Nov 10, 2005
Posts: 18
Originally posted by Rajagopal Manohar:
Hi Henry,

Thanks for the reply.

I tried


but it did not work.

is there any other way workaround by which I can keep those windows from popping up.

Thanks,
Rajagopal


There is really no reason for it to not work. Try to see the errors it produces, by checking its output. See Process methods getOutputStream, getErrorStream.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41137
    
  45
Check the Java Intermediate FAQ for some advice on how to use Runtime.exec.


Ping & DNS - my free Android networking tools app
Rajagopal Manohar
Ranch Hand

Joined: Nov 26, 2004
Posts: 183
Hello Guys,

Thanks for the replys, but the issue at hand is not how to get Runtime.exec() to work. I figured that one myself.

I am just desperate to know how to supress the dos command promt that pops up after running it.

Any pointers will be greatly appreciated

-Raj
[ November 16, 2005: Message edited by: Rajagopal Manohar ]
Rick Lohmeyer
Greenhorn

Joined: Nov 16, 2005
Posts: 2
When I want to run scheduled tasks without the aweful cmd window, I create a .vbs file. Below is an example of a running a scheduled Java application without the cmd window. You might try putting the commands you need to do your XCopy into a .vbs file. Just a suggestion.

Set ws= CreateObject("WScript.Shell")
ws.Run("F:\Java\jdk1.3.1_04\bin\javaw -cp .\\Multiples.jar;.\\Auxiliary.jar;F:\\Java\\j2sdkee1.3\\lib\\j2ee.jar serverTester.ReportSender GovHUB02 Rick.Lohmeyer true")
Rajagopal Manohar
Ranch Hand

Joined: Nov 26, 2004
Posts: 183
Hi Rick,

Great idea, can you go just one step futher to help me and let me know how to write a vbs script to do xcopy or atleast where I can learn to do it.

One more thing how to run vbs script from within java, ie are vbs scripts executable in the sense exe's are.

I am really very ignorant about these things, please help me

-Raj
Hemal Pandya
Greenhorn

Joined: Nov 10, 2005
Posts: 18
Originally posted by Rajagopal Manohar:
Hello Guys,

Thanks for the replys, but the issue at hand is not how to get Runtime.exec() to work. I figured that one myself.

I am just desperate to know how to supress the dos command promt that pops up after running it.

Any pointers will be greatly appreciated

-Raj

[ November 16, 2005: Message edited by: Rajagopal Manohar ]


What does "does not work" mean. I wrote a small program to test, and it works. That is, it copies the files and does not pop-up the command window.

Can you post your code and describe what happens when you run it?
Rajagopal Manohar
Ranch Hand

Joined: Nov 26, 2004
Posts: 183
Originally posted by Hemal Pandya:


What does "does not work" mean. I wrote a small program to test, and it works. That is, it copies the files and does not pop-up the command window.

Can you post your code and describe what happens when you run it?


Hi Hemal,

If you run a standalone program from the command line I expect things to work out well.

But I am running it from a GUI application. An eclipse pluginm, when we do that a Dos command promt pops up when we run the xcopy. This command promt is what I want to supress. I just want to know is there a better way than just minimising it.

any help will be appreciated.

-Raj
Hemal Pandya
Greenhorn

Joined: Nov 10, 2005
Posts: 18
Originally posted by Rajagopal Manohar:

[swing causes dos window to pop-up on Runtime.exec("xcopy")]



Can you post some *small* sample code that demonstrates this?
 
Don't get me started about those stupid light bulbs.
 
subject: How to prevent a MS DOS window popping up when I run cmd.exe from java
 
Similar Threads
Dos Window Flashs up ..
run dos window in minimized mode
Hiding Dos Prompt window
Diff between execution from IDE and double clicking on the exe file?
How to run simple windows commands through java program?