x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Error when trying to use exec in java

allans Page Icon Posted 2008-12-08 10:22 AM
#
Avatar image of allans
H/PC Newbie

Posts:
15
Status:
I need to execute a batch file from my java code and am having trouble getting it to work on Windows CE. Although testing seems to indicate I am having a broader issue. Every command I have tried in Runtime.getRuntime().exec(cmd) throws the exception:
java.IOExeception: CreateProcess: mycmd error=2

Initially 'mycmd' was the batch file I wanted to run, but with the last test I tried, it was a simple"cd" and that generated the same error.

Anyone know how I can get java/WinCE to cooperate?

* machine: LC7000 (X86 architecture)
* OS:WinCE 5.0
* CrE-ME V4.12 jvm (Evaluation version)

Thanks!
 Top of the page
allans Page Icon Posted 2008-12-08 3:09 PM
#
Avatar image of allans
H/PC Newbie

Posts:
15
Status:
Additional information. I found that:
Runtime.getRuntime().exec("/Hard Disk/redit.exe") works, but
Runtime.getRuntime().exec("/Hard Disk/foobar.bat") fails as above.

foobar.bat exists and executes just fine from the command line (it's a single echo statement).

Edited by allans 2008-12-08 3:13 PM
 Top of the page
C:Amie Page Icon Posted 2008-12-08 3:58 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,976
Location:
United Kingdom
Status:
Does your device have .bat registered as an executable file type? If .bat isn't a registered exension, then naturally it will be unable to do anything with it.

Try:
/hard disk/windows/cmd.exe /hard disk/foobar.bat
 Top of the page
allans Page Icon Posted 2008-12-08 4:43 PM
#
Avatar image of allans
H/PC Newbie

Posts:
15
Status:
I'm new to CE and do not know how to check or set .bat as executable. I assumed that since it worked from the command line, that it was considered such.

But, the solution is as you suggested:
Runtime.getRuntime().exec("/windows/cmd.exe /C \"/Hard Disk/foobar.bat\"");


Edited by allans 2008-12-08 4:44 PM
 Top of the page
C:Amie Page Icon Posted 2008-12-08 5:08 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,976
Location:
United Kingdom
Status:
You need to add the .bat handler to HKCR in the registry.

Happy to help.
 Top of the page
allans Page Icon Posted 2008-12-08 6:34 PM
#
Avatar image of allans
H/PC Newbie

Posts:
15
Status:
Thanks.
After your other post, I did some digging around in the registry. I found HKCR/.bat/Default with a value of 'cmdfile'.
HKCR/cmdfile/shell/open/command/Default has a value of '\\Windows\cmd.exe /C %1' so it appears to my limited experience that batch files are registered as executable.

This has driven me to another problem only tangentially related to my original post.
Double-clicking on a batch does not seem to execute the file.
Double-clicking on a shortcut to a batch also seems to do nothing.

Are these possible (especially the latter)?
 Top of the page
Alt Bass Page Icon Posted 2008-12-09 3:04 PM
#
Avatar image of Alt Bass
H/PC Sensei

Posts:
1,169
Location:
Russia
Status:
There are extensions stored in HKCR - .xxx. There is link to the filetype stored in "Default" value. The filetype contains some info.
That is:

HKCR/.xxx
Default = "xxxfile"

HKCR/xxxfile
Default = "[Filetype Name]"

HKCR/xxxfile/shell/open/command
Default = "[Path to the executable (cmd.exe for bat)] [additional commands]"

HKCR/xxxfile/DefaultIcon (optional link to the icon for the filetype)
Default = "[Path to library] -[number of icon]"

Edited by JHack 2008-12-09 3:05 PM
 Top of the page
allans Page Icon Posted 2008-12-09 4:09 PM
#
Avatar image of allans
H/PC Newbie

Posts:
15
Status:
JHack, thanks for the response and clarification!

As I noted above, the system I am working on has:
HKCR/.bat/Default = 'cmdfile'
and
HKCR/cmdfile/shell/open/command/Default = '\\Windows\cmd.exe /C %1'
but double-clicking has seems to have no effect (other than a windows briefly flashing).

Concrete example:
foobar.bat contains a single line:
echo I am here > test.txt

If I type 'foobar' on the command line, test.txt gets created and has the statement, "I am here", in it.
If I double-click on foobar.bat (or a shortcut to it), a window flashes very briefly, but no test.txt file is created.

Also, it appears that the redit.exe I have does not let me add keys to the registry. I can create, delete & modify values, but not keys. Help |ABout says "REdit Version 1.0".
I found redit_x86emdbg.exe on http://www.codeproject.com/KB/mobile/redit.aspx?fid=3282&df=90&mpp=... which lists the same author, but it appears to need mfcce300d.dll when my system only has mfcce400.dll.
Is there a redit that will let me add a key?
 Top of the page
C:Amie Page Icon Posted 2008-12-09 5:13 PM
#
Avatar image of C:Amie
Administrator
H/PC Oracle

Posts:
17,976
Location:
United Kingdom
Status:
I'm not aware of any regedit for CE that accepts params. You can get mfcce300 from hpcfactor.com\developer
 Top of the page
allans Page Icon Posted 2008-12-09 6:46 PM
#
Avatar image of allans
H/PC Newbie

Posts:
15
Status:
I don't want to launch with parameters.
I want to add a HLCR/.log key containing values that mirror .txt.
 Top of the page
Alt Bass Page Icon Posted 2008-12-12 6:27 AM
#
Avatar image of Alt Bass
H/PC Sensei

Posts:
1,169
Location:
Russia
Status:
Quote
allans - 2008-12-10 12:09 AM

foobar.bat contains a single line:
echo I am here > test.txt

If I type 'foobar' on the command line, test.txt gets created and has the statement, "I am here", in it.
If I double-click on foobar.bat (or a shortcut to it), a window flashes very briefly, but no test.txt file is created.




The reason may be stupid... Try enclosing %1 in double quotes.)

And what about registry... Try Total Commander. )
http://ghisler.com/wince2x.htm
For x86.

Edited by JHack 2008-12-12 6:32 AM
 Top of the page
allans Page Icon Posted 2008-12-12 3:28 PM
#
Avatar image of allans
H/PC Newbie

Posts:
15
Status:
Thanks JHack!!
"%1" did the trick!
Both the original batch file and shortcuts to it now will execute!

TC appears to require ActiveSync to install. I do not have ActiveSync and currently have no plans to use it. Adding a registry key was something that would just be a convenience. It is not necessary. Thanks anyway!
allan
 Top of the page
Alt Bass Page Icon Posted 2008-12-14 8:34 AM
#
Avatar image of Alt Bass
H/PC Sensei

Posts:
1,169
Location:
Russia
Status:
There's a cab file for x86 which should be opened on the handheld.
http://ghisler.fileburst.com/ce/tcmdwincex86em.cab
No ActiveSync needed.)
 Top of the page
Jump to forum:
Seconds to generate: 0.203 - Cached queries : 53 - Executed queries : 26