For Programmers: Free Programming Magazines  


Home > Archive > Java Help > April 2007 > exec









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author exec
Jean Pierre Daviau

2007-04-22, 10:06 pm

Hi everyone,

I can get this working:

Process p = null;
Runtime r = Runtime.getRuntime();
p = r.exec("EmailMoi.bat");
p.waitFor();

------ EmailMoi.bat"); ----
set >>Email_moi_back.txt
tree.com C:\\ >>Email_moi_back.txt
------
java.io.IOException: CreateProcess: EmailMoi.bat error=2
at java.lang.Win32Process.<init>(Compiled Code)
at java.lang.Runtime.exec(Compiled Code)
at java.lang.Runtime.exec(Runtime.java:122)
at Property.getEnvVars(Compiled Code)
at Property.main(Compiled Code)
--

p = r.exec("cmd.exe /c EmailMoi.bat");


runs without complain but the result are not printed to the file.


Thanks for your attention.

Jean Pierre Daviau
--
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Processor Radeon7000 0x5159 agp


Jean Pierre Daviau

2007-04-22, 10:06 pm

I just red

See http://mindprod.com/jgloss/exec.html for details.


"Jean Pierre Daviau" <Once@WasEno.ugh> a écrit dans le message de
news: WNOWh.12150$q97.87051@wagner.videotron.net...
> Hi everyone,
>
> I can get this working:
>
> Process p = null;
> Runtime r = Runtime.getRuntime();
> p = r.exec("EmailMoi.bat");
> p.waitFor();
>
> ------ EmailMoi.bat"); ----
> set >>Email_moi_back.txt
> tree.com C:\\ >>Email_moi_back.txt
> ------
> java.io.IOException: CreateProcess: EmailMoi.bat error=2
> at java.lang.Win32Process.<init>(Compiled Code)
> at java.lang.Runtime.exec(Compiled Code)
> at java.lang.Runtime.exec(Runtime.java:122)
> at Property.getEnvVars(Compiled Code)
> at Property.main(Compiled Code)
> --
>
> p = r.exec("cmd.exe /c EmailMoi.bat");
>
>
> runs without complain but the result are not printed to the
> file.
>
>
> Thanks for your attention.
>
> Jean Pierre Daviau
> --
> windows Xp
> asus p4 s533/333/133
> Intel(R) Celeron (R) CPU 2.00 GHz
> Processor Radeon7000 0x5159 agp
>



Jean Pierre Daviau

2007-04-22, 10:06 pm

It seems it needs absolute path of the file:

File a = new File("Property.java");
String b = a.getCanonicalPath();
File c = new File(b);
String fichier = command + c.getParent()+"\\Email_moi_back.txt";

"command.com /C set>>c:\\etc\\Email_moi_back.txt"


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com