Launch browser with current file

English main discussion
Post Reply
  • Author
  • Message
Offline
Posts: 7
Joined: Fri Sep 03, 2010 7:10 pm

Launch browser with current file

Post by bill »

Exec("C:\Program Files\Mozilla Firefox 4.0 Beta 3\firefox.exe '%f'").

This doesn't work. How does one launch Firefox, or any browser, displaying the current file?

Thanks.

Offline
Posts: 26
Joined: Sun Mar 02, 2008 12:53 pm

Post by infimum »

There is a space between "Program" and "Files" and other places.

Offline
Posts: 7
Joined: Fri Sep 03, 2010 7:10 pm

Post by bill »

It is enclosed in quotes. If I name a file it works perfectly. For example,

Exec("C:\Program Files\Mozilla Firefox 4.0 Beta 3\firefox.exe c:\links.htm")

But if I use the variable %f enclosed in single quotes it doesn't work. Why not?

Offline
Posts: 7
Joined: Fri Sep 03, 2010 7:10 pm

Post by bill »

Sorry. Solved it. Quotes around the variable are not needed. This works:

Exec("C:\Program Files\Mozilla Firefox 4.0 Beta 3\firefox.exe %f")

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

bill
I think this should be done like this:
Exec(`C:\Program Files\Mozilla Firefox 4.0 Beta 3\firefox.exe "%f"`)
or
Exec('C:\Program Files\Mozilla Firefox 4.0 Beta 3\firefox.exe "%f"')

Offline
Posts: 7
Joined: Fri Sep 03, 2010 7:10 pm

Post by bill »

That is the way I had it initially, double quotes around the complete string and single quotes around the variable. But I find that quotes around the variable are not needed. In fact, using quotes around %f doesn't work.

Offline
Posts: 119
Joined: Sat Jan 12, 2008 10:16 am
Location: Shantou, China

Post by cnnnc »

Exec(`"C:\Program Files\Mozilla Firefox 4.0 Beta 3\firefox.exe" %f`)

r0n
Offline
Posts: 23
Joined: Sat Jun 14, 2014 3:56 am

Post by r0n »

Sorry for bumping this topic up, can the above firefox path also be used in the "AkelPad.Exec" command?

This the command I used in for the "Scripts" plugin.

I have code below (see "I") that works perfectly with notepad, but if I replace 'notepad.exe' with the full path of another application it does not work.
If I replace 'notepad.exe' with the full absolute path to notepad.exe it also doesn't work.

I looked in the 'Scripts' section in the Plugins help-file but I could not find an awnser there.

Code: Select all

var hSubClass;

if (hSubClass=AkelPad.WindowSubClass(1 /*WSC_MAINPROC*/, MainCallback, 0x436 /*AKDN_OPENDOCUMENT_FINISH*/))
{
  //Message loop
  AkelPad.WindowGetMessage();

  AkelPad.WindowUnsubClass(1 /*WSC_MAINPROC*/);
}

function MainCallback(hWnd, uMsg, wParam, lParam)
{
  if (uMsg == 0x436 /*AKDN_OPENDOCUMENT_FINISH*/)
  {
    var filePath = AkelPad.GetEditFile(0);
    AkelPad.Exec("notepad.exe \"" + filePath + "\"");
  }
}
Is there a way to use a full path with an argument, using the following 2 variables:

Code: Select all

var msg_txt="Hello!" // this is the argument
var msg_exe="d:\path\to\msg_exe" // this generates a popup
I want to put the above 2 variables in the following line:

Code: Select all

AkelPad.Exec("notepad.exe \"" + filePath + "\"");

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

r0n

Code: Select all

var msg_txt='Hello!'; // this is the argument
var msg_exe='d:\\path\\to\\msg_exe'; // this generates a popup
AkelPad.Exec('"' + msg_exe + '" ' + msg_txt);
In JScript double backslashes are required: http://www.w3schools.com/js/js_strings.asp

r0n
Offline
Posts: 23
Joined: Sat Jun 14, 2014 3:56 am

Post by r0n »

I totally forgot about that!
It works, thank you!!!
Post Reply