Run Program with Arguments

5 replies [Last post]
รูปภาพของ nicholas
Joined: 02/01/2009
Posts: 326
User offline. Last seen 1 สัปดาห์ 6 วัน ago.

Buttons

Runs a program with some given arguments. These must be specified within the button.

Additionally, windows systems may need to double escape their backslashes.
C:\\Program Files\\...

I am not sure on that, but I think it is right.

Run Program with Arguments
Compatibility: 

Firefox 3.0.* Firefox 2.0.* Firefox 1.5.* Flock Thunderbird 3.* Thunderbird 2.*

Author(s): 
nicholas
Description & info:

Behavior

Action Behavior

Left

Launch pre-programmed application with specified arguments

รุ่น

リビジョン 操作
04/13/2009 - 09:28 - rawny

Cleaned up description, re-formatted behaviour, added categories, added behaviour information to button's help, removed duplicate code in the initialisation tab, bumped button version and re-posted it with these changes.

現在のリビジョン
03/02/2009 - 11:12 - admin

update compatibility field

02/27/2009 - 19:45 - admin
02/25/2009 - 17:36 - rawny
02/22/2009 - 23:35 - SCAdmin
02/22/2009 - 22:10 - SCAdmin

Moved Post

รหัส

javascript: Copy To Clipboard
/*Code*/
 
function runProgram(progPath, arg)
{
  var argArray = arg ? arg.split(/\s+/) : [];
  var nsILocalFile = Components.classes["@mozilla.org/file/local;1"]
      .getService(Components.interfaces.nsILocalFile);
  var nsIProcess = Components.classes["@mozilla.org/process/util;1"]
      .getService(Components.interfaces.nsIProcess);
  nsILocalFile.initWithPath(progPath);
  nsIProcess.init(nsILocalFile);
  nsIProcess.run(false, argArray, argArray.length);
  nsIProcess.close();
  return nsILocalFile;
}
runProgram("/usr/bin/thunderbird","-safe-mode");

Init

javascript: Copy To Clipboard
// button attributes
this.style.opacity = '.65';
this.setAttribute("onmouseover", "if (custombuttons) custombuttons.ButtonBrt(event);");
this.setAttribute("onmouseout", "if (custombuttons) custombuttons.ButtonDim(event);");
 
this.setAttribute('author','nicholas');
this.setAttribute('version','20090413.00');
this.setAttribute('homepage', 'http://custombuttons2.com/forum/buttons/buttons-database/run-program-arguments.html');
this.setAttribute('dependency','FF3.0*, FL2.0*, TB2.0*, CB2 2.0.5*');
this.setAttribute('status','Complete');
this.setAttribute('public',true);

คู่มือการใช้งาน

Left: Launch pre-programmed application with specified arguments

รายละเอียด

Button Categories: 
Top
Joined: 01/28/2009
Posts: 3
User offline. Last seen 1 ปี 6 สัปดาห์ ago.

Hi! I want to launch programs from Thunderbird Portable which is on my USB key. For this I need to use relative paths. How can I do this with your button?
-thanks

Custom Buttons² v.2.0.9.10

Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)

Top
Joined: 04/11/2009
Posts: 3
User offline. Last seen 1 ปี 20 สัปดาห์ ago.

Hi I could get this button to open up windows explorer but is there a way to set arguments eg the /e switch will open upon explorer in tree view from the run box:

c:\windows\explorer.exe /e

Thanks,

WB

Custom Buttons² v.3.0.0

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20

Posted with the theme Pluralism

Top
รูปภาพของ morat
Joined: 01/31/2009
Posts: 188
User offline. Last seen 6 ชั่วโมง 6 นาที ago.

open Windows Explorer to C:\

javascript: Copy To Clipboard
/*Code*/
var file = Components.classes["@mozilla.org/file/local;1"].
  createInstance(Components.interfaces.nsILocalFile);
var process = Components.classes["@mozilla.org/process/util;1"].
  createInstance(Components.interfaces.nsIProcess);
var args = ["/e"];
file.initWithPath("C:\\WINDOWS\\explorer.exe");
process.init(file);
process.run(false, args, args.length);

open Windows Explorer to C:\Program Files\Mozilla Firefox

javascript: Copy To Clipboard
/*Code*/
var file = Components.classes["@mozilla.org/file/local;1"].
  createInstance(Components.interfaces.nsILocalFile);
var process = Components.classes["@mozilla.org/process/util;1"].
  createInstance(Components.interfaces.nsIProcess);
var args = ["/e,","C:\\Program Files\\Mozilla Firefox"];
file.initWithPath("C:\\WINDOWS\\explorer.exe");
process.init(file);
process.run(false, args, args.length);

Custom Buttons² v.3.0.0

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8

Posted with the theme Pluralism

Top
Joined: 04/11/2009
Posts: 3
User offline. Last seen 1 ปี 20 สัปดาห์ ago.

Thanks, that was a big help. I got it working.

WB

Custom Buttons² was not found: find out why...

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20

Posted with the theme Pluralism

Top
Joined: 10/04/2009
Posts: 1
User offline. Last seen 47 สัปดาห์ 4 วัน ago.

I would like to execute an external script passing selected mails or usenet articles as text to my external script. Is that possible?

Custom Buttons² was not found: find out why...

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3

Posted with the theme Pluralism

Top