• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.io.IOException: Cannot run program "cmd.exe": CreateProcess error=5, Access is denied

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a part of diagnostic effort we copied cmd.exe from system32 folder of windows to C:\\ drive and tried to run from an applet and get following exception :

java.io.IOException: Cannot run program "cmd.exe": CreateProcess error=5, Access is denied

The problem is with JRE 1.7 whereas on JRE 1.6 it runs fine.

Renamed it to cmdx , runs fine.

So any program named as cmd does not run at all.

The applet jar is signed.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alka, welcome to the Ranch! Please BeForthrightWhenCrossPostingToOtherSites
http://www.java-forums.org/advanced-java/63494-java-io-ioexception-cannot-run-program-cmd-exe-createprocess-error-5-access-denied.html
https://forums.oracle.com/forums/thread.jspa?threadID=2446927

db
 
Alka Gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More information

Runtime.getRuntime().exec(new String[] { "C:\\cmd.exe"});

as well as

Process p = new ProcessBuilder("C:\\cmd").start();

None of them work, It used to work before with jre 1.6 and now we started certifying 1.7 for our software we this issue.

I have read many forums and have asked on Java forum, windows forum and oracle forum but I havent got any answer yet
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I must be missing something . Why do you need to name the executable you are trying to exec() cmd.exe ? Why can't you call it something like fred.exe ?
 
Alka Gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", udoc.getFilename() });

This is the original code I'm trying to execute and fails on cmd.exe so I broke it to see how can I fix the cmd problem
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wasn't this adequately answered hours earlier in one of the cross posts?
 
Alka Gupta
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That didnt solve my problem, I am still having the issue
 
Richard Tookey
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alka Gupta wrote:Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", udoc.getFilename() });

This is the original code I'm trying to execute and fails on cmd.exe so I broke it to see how can I fix the cmd problem



So can we start again. The copying of cmd.exe is a red-herring and all you are trying to do is execute a 'bat' file using Runtime.exec() but it fails. Have you read all the parts of http://www.javaworld.com/jw-12-2000/jw-1229-traps.html and implemented ALL the recommendations? If not then do so and post the code, all the error messages, the process 'stdout' content, the process 'stderr' content and the process exit code.

Note - I use Runtime.exec() to execute 'BAT' files without problems on Windows Xp and Windows 7. The single most important thing to do is to fully read the 'stdout' and 'stderr' streams in separate threads and for diagnostic purposes one needs to print the content.

You seem to be doing this within an Applet so you must of course sign the Applet. To make it easy to test the code you should isolate the whole into it's own class; you can then do the basic tests without having to continually deploy the applet and clear the Applet cache. Once you have the basics working you can then use this class in the Applet.


reply
    Bookmark Topic Watch Topic
  • New Topic