I have strange problem with run .exe program in my WebApplication. It works fine in console mode.
My exe application code:
...
Console.WriteLine("before getEnvirement");
IDictionary environmentVariables = Environment.GetEnvironmentVariables();
foreach (DictionaryEntry de in environmentVariables)
{
Console.WriteLine(" {0} = {1}", de.Key, de.Value);
}
Console.WriteLine("before new Application");
this.application = new App();
Console.WriteLine("after new Application");
...
Where App() is class from COM library (I added reference of course).
My Java console / WebApplication code:
try {
String[] callAndArgs = {"C:\\temp\\program.exe", "arg1", "arg2"};
Process p = Runtime.getRuntime().exec(callAndArgs);
p.waitFor();
} catch (IOException e) {
System.out.println("IOException Error: " + e.getMessage());
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
}
Output in "console mode" (correct):
before getEnvirement
<all my envirements>
before new Application
after new Application
Output in "web application mode" (bad):
before getEnvirement
Path = C:\Windows\system32; <...>
TEMP = C:\Windows\TEMP
or when I delete getEnvirement code (also bad):
before getEnvirement
before new Application
Exe application won't close itself on tomcat (I must use task manager to kill it)
And my questions: Why it dosn't work correct on tomcat? Why exe program have problems with getting system envirements when I run it on tomcat? And finally: why it works in console mode? :)