topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 6:30 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: passing parameters to .exe and .bat  (Read 12761 times)

burro

  • Participant
  • Joined in 2008
  • *
  • Posts: 4
    • View Profile
    • Donate to Member
passing parameters to .exe and .bat
« on: August 15, 2008, 09:51 AM »
New convert here, from... well, some "other tool" :).  Really enjoying the flexibility that FARR is giving me!

Got a quick question.  What is the best way to call a program (be it .exe or .bat or .whathaveyou) with some parameters that I type?  For instance:

%SystemRoot%\System32\mstsc.exe /v:%1

I've tried to make an alias that looks like this:

match on: ^rd (.*)
Run: Remote Desktop | %SystemRoot%\System32\mstsc.exe /v:$$1

But that doesn't seem to do the trick.  I seem to have a lot of other .exe programs that I run on a regular basis that take parameters.  How can I do this?  Been looking around in the forum and on the docs, but I must be blind.

Thanks a ton.  Awesome tool!  Hopefully will be giving some scripts back to the community soon.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #1 on: August 15, 2008, 11:15 AM »
three things:

First, welcome!

Second, that alias you specified should work fine -- i think it's important for you/me/us to figure out why its not working properly if it isnt.  Can you tell me any more symptoms, like is it launching the program but without arguments, or not launching it at all.

Third, people have been requesting an easier way to pass parameters to a tool for a while now, and i think it's time for me to add it.  The idea that i think we settled on for how to do this is to allow some way to express on the search line that you want to pass extra paramaters to the launched program, like: "search terms :: param1 param2"  that would tell far that whatever you type after the :: should be passed as commandline parameters.  Thoughts?

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #2 on: August 15, 2008, 01:19 PM »
My suggestions

"searchterm tab arguments."
"searchterm > arguments."
"searchterm | arguments."




burro

  • Participant
  • Joined in 2008
  • *
  • Posts: 4
    • View Profile
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #3 on: August 15, 2008, 01:26 PM »
Well, seems like the machine needed a restart :(  I haven't changed anything and the alias does work as expected, as in, it does bring up the Remote desktop tool with the appropriate machine.

I like your idea of having some sort of string that can be used to specify arguments.  Personally, I have a lot of these programs that I need to pass parameters to, and making an alias for each of them has been a bit annoying.  I have managed to make it work though.  I'm wondering if making the string be "$$" instead of "::" would make it more obvious, as "$$" is already used as a prefix to the parameters.

Thanks for the quick response!

d4ni

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 129
    • View Profile
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #4 on: August 24, 2008, 07:25 PM »
I am in favor of the pipe character, |, to split search terms from arguments. It just looks nice, as in it really splits the right and left part, so program from parameters :)

burro

  • Participant
  • Joined in 2008
  • *
  • Posts: 4
    • View Profile
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #5 on: August 25, 2008, 11:50 AM »
Well, it seems like I wasn't crazy in the head after all.  The remote desktop alias that I described in the original post is a real issue.  It is intermitent, and I have not been able to pin down the environment under which it fails and the one under which it works.  As of this writing it has gone back to "not working", and nothing in the config has changed that would seem to make this happen.  Any tips on how I can provide more data to aid debbugin?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #6 on: August 25, 2008, 11:58 AM »
try changing the launch method used by FARR on the General options tab.
if it's intermitant then maybe the problem is not with farr..


d4ni

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 129
    • View Profile
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #7 on: August 27, 2008, 06:41 PM »
Works fine iff you change %SystemRoot% to C:\Windows\ or equivalent for your system. Clearly it should work with the environment variable but as a temporary solution I guess you should just use the absolute path, or is it not possible?

Changing the launch method didn't fix the problem.

burro

  • Participant
  • Joined in 2008
  • *
  • Posts: 4
    • View Profile
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #8 on: August 28, 2008, 08:20 AM »
Some results:

For all, I had to replace the %var% with the absolute to make it work.

* With: Checked "Use document launch helper utility", used "Method 2 - ShellExecuteEx"
  - The "rd" alias works.
  - Opening a link to a file (which has assosiated program in explorer) does not work.

* With: Checked "Use document launch helper utility", used "Method 1 - ShellExecute"
  - The "rd" alias works.
  - Opening a link to the file works.

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 267
    • View Profile
    • Donate to Member
Re: passing parameters to .exe and .bat
« Reply #9 on: September 01, 2008, 04:27 PM »
Third, people have been requesting an easier way to pass parameters to a tool for a while now, and i think it's time for me to add it.  The idea that i think we settled on for how to do this is to allow some way to express on the search line that you want to pass extra paramaters to the launched program, like: "search terms :: param1 param2"  that would tell far that whatever you type after the :: should be passed as commandline parameters.  Thoughts?

Some way of passing commandline parameters is really needed. Perhaps launchy's method is the most intuitive one. Pressing Tab would add a special visual separator (a triangle if I recall correctly) behind the text in the searchbox and you could write any parameters needed. Now, since Tab is used to autocomplete there should be a check to see if currently selected item in the result list is executable or not before deciding what would be done (autocomplete or take commandline parameters).

In the meantime, here's my alias that helps a little:
1000>>>exec arguments>->$$1.$$2 $$3>+>(.*).(exe|bat) (.*)

Now the only thing to keep in mind is that you have to enter the full path to the desired application or utility (which is easily done by pressing Tab on the selected item)

Hope it helps,
skajfes
It is impossible to make anything foolproof because fools are so ingenious.