I'm writing an encoding program in AIR. Previously, another program was required (Directory Monitor) to watch a folder to be modified by AIR, and then Directory Monitor would start the encoding process. This process involves a batch file (.bat) calling a PERL script, which creates another .bat. The first batch file (the root bat) then calls that newly created .bat, which does some things using other progroms, and calls the .bat file necissary for the encoding of that particular codex (quicktime, directX, etc). After, that third batch file actually encodes the file by calling several different exe files (about 7 of them). Problem is, AIR won't allow the .bat that starts through AIR to call the PERL-created .bat. I have no idea why. I currently catch all output and display it in a <p> tag that I've made to look like a terminal window. I can't figure out how to call the next bat. Ideas? Here's my code (create two .bat files, and have the one you pass through in AIR call the second one. You'll see that AIR won't let that happen).
/* Testing the new NativeProcess */
// Check if native process is even supported
/* We first create a file object and attach it to our executable file. We pass that into a startupInfo object, which will be used to initialize the program. We will include in that our arguments to pass into the native application when it is started. "Native application" means that it's a Windows app, not AIR. We also, need to create a process handle, attach listeners (so we can pass in information and get the output into AIR to play with). Finally, we start the application. */
var file = new air.File();
//file = file.resolvePath("C:\\Documents and Settings\\me\\Desktop\\my\\applications\\directories\\TestScript.bat"); // Cannot start a .bat.
file = file.resolvePath("C:\\WINDOWS\\system32\\cmd.exe");
var nativeProcessStartupInfo = new air.NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
encodeProcess = new air.NativeProcess();
// Attach listeners to catch all outgoing data (through STDOUT), and to allow us to give additional input, if desired.
encodeProcess.addEventListener(air.ProgressEvent.STANDARD_OUTPUT_DATA, outputHandler); // Listener on STDOUT
encodeProcess.addEventListener(air.ProgressEvent.STANDARD_INPUT_PROGRESS, inputHandler); // Triggered by NativeProcess object when STDIN stream is flushed.
encodeProcess.addEventListener(air.NativeProcessExitEvent, processExited); // Triggered when the application exits. We need to remove all handles and listeners.
// Start the application.
// Create string to pass through as a command to our first batch file, and pass it through.
var command = "\"" + applicationRoot + "\\moviesInNeedOfEncoding\\encodeWatchFolders.bat\"\n";
alert("NativeProcess is not supported!");
} // End makeItGo()
/* When the application outputs something on STDOUT, we catch that event (the data) in the function below */
var consoleBox = document.getElementById("consoleOutput");
var data = encodeProcess.standardOutput.readUTFBytes(encodeProcess.standardOutput.bytesAvailable);
consoleBox.innerText += data;
/* Whenever input is sent to the console, this function makes sure the new output is shown in the console. Not sure it's needed, but it works with it in. */
/* This takes commands that we type in, and passes it along. */
var inputBox = document.getElementById("consoleInput");
inputBox.value = "";
/* Removes all listeners, closes the process, and removes the AIR handle on the process, allowing it to close. */
encodeProcess.exit(false); // False means don't force the exit.