Om de ûnderfining foar jo te ferbetterjen is tydlik de funksjonaliteit dan dizze website troch ûnderhâldswurk beheind. Wannear in artikel jo probleem net oplost en jo in fraach stelle wolle, kin ús stipemienskip jo helpe yn @FirefoxSupport op Twitter en /r/firefox op Reddit.

Sykje yn Support

Mij stipescams. Wy sille jo nea freegje in telefoannûmer te beljen, der in sms nei ta te stjoeren of persoanlike gegevens te dielen. Meld fertochte aktiviteit mei de opsje ‘Misbrûk melde’.

Mear ynfo

Dizze konversaasje is argivearre. Stel in nije fraach as jo help nedich hawwe.

Components.interfaces.nsIProcess 参数带空格会被截断,怎样才能用带空格的参数

  • 2 antwurd
  • 1 hat dit probleem
  • 2 werjeftes
  • Lêste antwurd fan mponeto

more options

写火狐扩展时发现,用Components.interfaces.nsIProcess,调用run函数,可以传入参数数组,但是单个参数内,如果包含空格,会被截断,只留空格前的内容,加双引号也没用,如果我要传的参数是带空格的路径,该如何处理 function hello() {

 var oURL = "c:/a/a x";
 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 var process = Components.classes['@mozilla.org/process/util;1'].getService(Components.interfaces.nsIProcess);
 var targetFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
 targetFile.initWithPath("D:/temp/a e/1.exe");
 process.init(targetFile);
 var arguments = [oURL];  
 process.run(false, arguments, arguments.length,{});

}

写火狐扩展时发现,用Components.interfaces.nsIProcess,调用run函数,可以传入参数数组,但是单个参数内,如果包含空格,会被截断,只留空格前的内容,加双引号也没用,如果我要传的参数是带空格的路径,该如何处理 function hello() { var oURL = "c:/a/a x"; netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var process = Components.classes['@mozilla.org/process/util;1'].getService(Components.interfaces.nsIProcess); var targetFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile); targetFile.initWithPath("D:/temp/a e/1.exe"); process.init(targetFile); var arguments = [oURL]; process.run(false, arguments, arguments.length,{}); }

Alle antwurden (2)

more options

You can't use such code in current Firefox releases. Support for enablePrivilege stopped long ago, so this is not possible.

Only an extension would be able to run code that needs chrome privileges.

more options

我就是在写扩展的时候发现这个问题的,路径参数数组中,参数带空格会被截断