wood burning stoves*
The moose likes I/O and Streams and the fly likes exec and cmd.exe / command.com on Win Server 2003 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "exec and cmd.exe / command.com on Win Server 2003" Watch "exec and cmd.exe / command.com on Win Server 2003" New topic
Author

exec and cmd.exe / command.com on Win Server 2003

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
Ok, I've read a bunch of the info in forum posts related to using exec and detecting which version of Windows you're running so you know whether to call cmd.exe or command.com, and also how sometimes when executing a 16-bit program like PkUnzip you can get an error mentioning NTVDM.exe and how your environment is not set up correctly. Here are examples of what I'm talking about:

http://forum.java.sun.com/thread.jsp?thread=277541&forum=31&message=2516319

http://forum.java.sun.com/thread.jsp?forum=31&thread=523974

This problem occurring on Windows Server 2003 isn't mentioned anywhere, and while I wouldn't imagine it being very different from XP or 2000, the solution for Win 2003 wasn't the same as for them, at least according to the code in that second link above. Basically, I first tried to exec PKUNZIP, and then I tried calling exec("command.com", "/c", pathToPKUNZIP...) and that didn't worked, so I changed command.com to cmd.exe and it currently works, though earlier what I had written worked (an exec on PKUNZIP without cmd or command.com) and then it stopped working again (and I don't know what I did--opened and closed a few cmd/command windows manually?). When exec is invoked in Windows, do you think it's more similar to command.com or cmd.exe, or is this even worth me asking? I know this is rambling, but I'm just trying to grasp what's going on so I can ensure this works when it needs to! Does it matter that to begin with, my Java program gets invoked from a Windows .bat file? I assume that means it loads up cmd.exe...

Here is my code that uses the old PKUNZIP to unzip a password-protected file:




I changed the first line to this and it currently works:




However, as I mentioned, before it worked for only a few hours and I have no idea whether anyone changed ANYTHING on that server! Any idea as to what is going on?
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Some windowses have cmd.exe, and some have command.exe.

2000, xp: cmd.exe
95, 98: command.exe

so far I know.

Did you allways use the same zipfile?
Is there some output generated? If yes, this might be an issue, if you don't consume System.in / out.


http://home.arcor.de/hirnstrom/bewerbung
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I'm on XP and I have both cmd and command. Try the help on each. They are not the same.

cmd /?
command /?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exec and cmd.exe / command.com on Win Server 2003
 
Similar Threads
Problem in unzipping a folder using java.util.zip API
Implementing runAs in Java
problem calling isql or osql from java
Runtime.exec( ) is hanging....
System.exit() capture using bat or shell script