I want to execute a javascript that ret开发者_如何学Gourns a string like 'GEORGE SMITH'. I want to read that information but when y run this code I get: " The specified executable is not a valid Win32 application"
How can i capture this information?. I tried to call the javascript from a .bat but I cannot get the output from there. Can anyone help me?.
This is the code:
{
Process proc = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.FileName = "cardholder.js";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo = startInfo;
proc.Start();
nombreApellido = proc.StandardOutput.ReadToEnd();
proc.Close();
proc.Dispose();
}
javascript file is not an executable and you cannot run it.
You need to run wscript.exe and pass cardholder.js as a command line argument:
startInfo.FileName = "wscript.exe";
startInfo.Arguments= "cardholder.js";
cardholder.js is not an executable. Your startInfo.FileName needs to be an executable. You will need a javascript interpreter to 'run' the .js file.
精彩评论