Closed Bug 421751 Opened 16 years ago Closed 16 years ago

nsIProcess should not open command consoles when running batch files

Categories

(Core :: XPCOM, defect)

x86
Windows Vista
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: hello, Assigned: hello)

References

Details

Attachments

(1 file)

When nsIProcess is used to run a batch file in Windows a command prompt window will pop up.  Depending on how quickly the batch file runs it may only flash on screen for a short time.  See the weave forums for more info, e.g.:

https://labs.mozilla.com/forum/index.php/topic,574.msg2064.html#msg2064
Attached patch patch v0Splinter Review
Thanks to dcamp for finding the flag I needed.
Assignee: nobody → thunder
Status: NEW → ASSIGNED
Attachment #308246 - Flags: review?(benjamin)
Comment on attachment 308246 [details] [diff] [review]
patch v0

This is fine.  It only effects console apps but doesn't work on win9x.  But we need a comment why this flag is important.  add that, and r=dougt
Attachment #308246 - Flags: review?(benjamin) → review+
Comment on attachment 308246 [details] [diff] [review]
patch v0

Thanks Doug.  I'll add this:

/* The CREATE_NO_WINDOW flag is important to prevent console
 * windows from appearing.  This makes behavior the same on
 * all platforms.  This won't work on win9x, however.  The flag
 * will not have any effect on non-console applications.
 */

Requesting superreview from :bs.
Attachment #308246 - Flags: superreview?(benjamin)
Attachment #308246 - Flags: approval1.9?
Comment on attachment 308246 [details] [diff] [review]
patch v0

Removing accidental a?
Attachment #308246 - Flags: approval1.9?
Attachment #308246 - Flags: superreview?(benjamin) → superreview?(mconnor)
Comment on attachment 308246 [details] [diff] [review]
patch v0

sr=mconnor
Attachment #308246 - Flags: superreview?(mconnor) → superreview+
Comment on attachment 308246 [details] [diff] [review]
patch v0

Thanks Mike.
Requesting a1.9...

I'd really like to get this into Fx3, it's super small and low-risk, and will make my life easier in Weave.

Let me know if you need any more info for why we want this now rather than wait.
Attachment #308246 - Flags: approval1.9?
Comment on attachment 308246 [details] [diff] [review]
patch v0

a1.9+=damons
Attachment #308246 - Flags: approval1.9? → approval1.9+
Committed:

/cvsroot/mozilla/xpcom/threads/nsProcessCommon.cpp,v  <--  nsProcessCommon.cpp
new revision: 1.25; previous revision: 1.24
this is change to previous behavior.
with my extenstion I would like to open command prompt window or see batch output and now it's impossible?

...
path = System32+"cmd.exe"
var file = Components.classes["@mozilla.org/file/local;1"]
				.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(path);
var process = Components.classes["@mozilla.org/process/util;1"]
				.createInstance(Components.interfaces.nsIProcess);

process.init(file);
var args = ["/k", "cd", "C:"];
process.run(false, args, args.length);
...
You can use nsILocalFile.launch() to get the window:

let f = Components.classes["@mozilla.org/file/local;1"]
  .createInstance(Components.interfaces.nsILocalFile);
f.initWithPath("C:\\WINDOWS\\system32\\cmd.exe");
f.launch();
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
It's not the same. How can you pass parameters with f.launch()?
You could run a batch file with all your parameters.
I am passing parameters to batch and other tools from FF.
With launch it is impossible.

Maybe better solution is to expose CREATE_NO_WINDOW flag in nsiProcess interface?!
It's not impossible, just requires an extra batch file:

runcmd.bat:
start cmd %*

mozilla:
let file = Components.classes["@mozilla.org/file/local;1"]
  .createInstance(Components.interfaces.nsILocalFile); file.initWithPath("C:\\path\\to\\runcmd.bat");
let proc = Components.classes["@mozilla.org/process/util;1"]
  .createInstance(Components.interfaces.nsIProcess)
proc.init(file);
let args = ["/k", "echo", "hi"];
proc.run(false, args, args.length);

Works for me.
This bug has found its way back into Shiretoko FF 3.5 beta.

I reported it as bug 485946:

https://bugzilla.mozilla.org/show_bug.cgi?id=485946
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: