• 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:

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

 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm on XP and I have both cmd and command. Try the help on each. They are not the same.

cmd /?
command /?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic