This content has been marked as final. Show 9 replies
Unless you need to setup the environment then set it to null.
Do not make the mistake of assuming that the working directory is where you script (.bat file) should be located. The script should be in a directory in the PATH.
Thanx for response, but I need to set both environment variables and working directory because my app works here (here read and write files).
Did you read what I said about the PATH? The implication of
is that you think that setting the working directory will mean you can execute scripts from there. They won't! The scripts directory has to be on the PATH.
String scriptsdir = "C:/workspace" File dir = new File(scriptsDir);
This si not my problem.
I need to execute this code: Runtime.getRuntime().exec(args, envp, dir) (method with three params) and I can't understand why same batch file (same args) works fine if I execute Runtime.getRuntime().exec(args) with one param.
In my batch file there is a call to a freeware utility command to send mail (blat), that create a socket to mail server
with your code (2nd example) you are able to run the batch file?
if yes, i think it's not a problem of PATH...
can you show your log error? it may be helpful, i think.
I'm able to run batch file only with first java code (first example)
This is blat log, in 2nd case:
2008.01.31 17:42:40 (Thu)------------Start of Session-----------------
Blat v2.6.2 w/GSS encryption (build : Feb 25 2007 12:06:19)
2008.01.31 17:42:40 (Thu): Error: Can't create a socket (too many simultaneous links?)
2008.01.31 17:42:40 (Thu)-------------End of Session------------------
I tried with another utility with same results
The 2nd example runs only if my batch file execute with copy call, and without blat command call
that's what i mean: you are able to run the batch file even in the 2nd example, but its execution fails calling 'blat service', isn't it?
sorry for my bad english...
yes, it is what happens