Cant create process: IOException

P

Prabh

Hello all,
I'm trying to run a cmd from WINXP from Runtime.exec.
I'm trying to open a file, "a.txt" in notepad.

The run fails with error:
"java.io.IOException: CreateProcess: "notepad a.txt" error=2"

The command used: "notepad a.txt"

The setup of the command I know is fine, because a command, "notepad"
alone works fine and brings up a notepad. Its when I pass some
arguments to notepad that it fails.

I tried quite a few permutations of the command:

notepad a.txt
notepad\ a\.txt
notepad\ a.txt
"notepad a.txt"
'notepad a.txt'

You get the general idea, but it doesnt work in any of these cases and
bombs.
A plain-vanilla notepad works fine.
Could someone please tell me what I'm doing wrong.

Thanks for your time,
Prab
 
C

Christophe Vanfleteren

Prabh said:
Hello all,
I'm trying to run a cmd from WINXP from Runtime.exec.
I'm trying to open a file, "a.txt" in notepad.

The run fails with error:
"java.io.IOException: CreateProcess: "notepad a.txt" error=2"

The command used: "notepad a.txt"

The setup of the command I know is fine, because a command, "notepad"
alone works fine and brings up a notepad. Its when I pass some
arguments to notepad that it fails.

I tried quite a few permutations of the command:

notepad a.txt
notepad\ a\.txt
notepad\ a.txt
"notepad a.txt"
'notepad a.txt'

You get the general idea, but it doesnt work in any of these cases and
bombs.
A plain-vanilla notepad works fine.
Could someone please tell me what I'm doing wrong.

Thanks for your time,
Prab

You need to pass a.txt as an argument.

Look at http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html for
the appropiate methods.

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html is also a
good resource on runtime.exec()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top