nsIProcess::Run fails with NS_ERROR_FILE_EXECUTION_FAILED with long arguments on WinXP




8 years ago
8 years ago


(Reporter: fyrenmoo, Unassigned)


Firefox Tracking Flags

(Not tracked)




8 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20101026 Firefox/3.6.12 (.NET CLR 3.5.30729)

I was writing a Firefox extension that needed to run an outside process that takes a list of links.  I have code that looks like this:

var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("my path");
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.run(false, args, args.length);
//args is a string array where each element is a single argument

It seems like when the total size (string length?) of the arguments is too high, calling run() errors.  With arguments "1", "2", ..., "50" it runs fine.  But with, for example, 25 arguments that are much longer, it errors.  The combined length of my arguments when it errors out is less than 2048 bytes.  In all cases I'm using the same executable.

Reproducible: Always

Steps to Reproduce:
1. Fill the args in the sample code with a pile of long arguments.
2. Call run().
Actual Results:  
I get a popup saying "Windows cannot access the specified device, path, or file.  You may not have the appropriate permissions to access the item."  The title of the popup is the path to my executable.

Expected Results:  
I would expect the call to run to succeed or for there to be a more useful error message.  In cases where it fails, being told the file can't be accessed is rather strange, even if it's Windows showing it to me instead of directly being Firefox's doing.

nsProcess::Run uses ShellExecuteEx and MSDN doesn't say much about how long the parameters can be.  MSDN does say the argument string for CreateProcess can be up to 32kbytes long.
You need to log in before you can comment on or make changes to this bug.