I have a method that I call on PageLoad of an aspx (the method will later be moved to a file in the AppCode dir) that looks like this:
public partial class PagesSystem_TestGCC : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strCmdText;
strCmdText = "/K java -jar c:\\TheSite\\compiler.jar --js
c:\\TheSite\\JSTest\\hello.js --js_output_file
c:\\TheSite\\JSTest\\hello-compiled.js";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
}
}
The problem is that this approach relies on using the computer's file system. What do I need to change in my code to make it work with the application's root?
the command line window flickers open and then closes, without a chance to see what's going on
Use "cmd.exe /K ...
instead of "cmd.exe /C ...
.
I think that your actual problem is either access permissions or not having java.exe
in the PATH
of the ASP.Net user.
Use this code:
System.Diagnostics.Process.Start(
new ProcessStartInfo {
FileName = "java.exe",
Arguments = "-jar compiler.jar --js JSTest/hello.js --js_output_file JSTest/hello-compiled.js",
WorkingDirectory = HttpRuntime.AppDomainAppPath,
UseShellExecute = false
}
);