Run program with file in Source, but work in Target panel?

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
AKE
Junior Member
Junior Member
Posts: 14
Joined: 2012-09-05, 03:45 UTC
Location: London, UK
Contact:

Run program with file in Source, but work in Target panel?

Post by *AKE »

Hi:

Trying to configure a button to run whatever program is selected in the target (inactive) pane while taking as command-line argument the file selected in source (active) pane **AND** which places output of program into target (inactive) pane alongside the program itself...

Cannot specify a fixed start path since I want the button to work on any program that could be anywhere. Can't leave the start path blank, because then by default it uses source pane...

An ideal solution would be putting %T into start path field... but I don't think that's allowed (it doesn't seem to work)?

Note: Am using TC 8.50 on WinXP / 7.

Open to any suggestions or methods for doing this.

Many thanks!



P.S. Below I've shown how I am currently doing something similar but backwards from what I'm after.

Backwards method:

Use a hammer.bat file containing:
call %1 %2

Configure the button to call hammer.bat with %P%N %T%M as parameters.

Unfortunately, PROGRAM must be in source pane and PARAMETER in target. (I want it the other way.)

This correctly puts output with program (in source pane).

User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Try following button:

Code: Select all

Command: cmd.exe
Parameters: /c "@echo off & pushd "%T" & start "" "%T\%M" "%P%O.%E""
Start path: <empty, doesn't matter>
Minimized: <yes>
It works just like batch file, but with no physical batch file. And, it sets working path to target panel path before starting program that is focused in target panel.
User avatar
AKE
Junior Member
Junior Member
Posts: 14
Joined: 2012-09-05, 03:45 UTC
Location: London, UK
Contact:

Post by *AKE »

@MVV:

Brilliant! That works a charm.
Parameters: /c "@echo off & pushd "%T" & start "" "%T\%M" "%P%O.%E""
What's the reason why the above uses start and not call?

As it stands, two cmd windows flash up and it would be nice if there were just the one.

I'm assuming the first cmd window is due to cmd.exe launching and the second is due to start...

Thanks!!
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

start command executes program just like TC button, or Win+R, or command line, while call was made for executing batch files with return to previous batch file. And, start runs program and returns control to batch file w/o waiting by default.

There should be only one black window if you enable minimized mode for button. You can also try following, it won't add second black window but first one will wait until program terminates:

Code: Select all

Parameters: /c "@echo off & pushd "%T" & "%T\%M" "%P%O.%E""
(i.e. same but with starting program directly w/o start command; it will work with executables, also it will work with batch files because you don't need to return control to your batch)
User avatar
AKE
Junior Member
Junior Member
Posts: 14
Joined: 2012-09-05, 03:45 UTC
Location: London, UK
Contact:

Post by *AKE »

Ah, yes, minimising works...

But even better!: you answered the problem I was just having with batch files!... :D

Playing around, can it be shortened without losing features?

Attempting to Shorten it?...

Code: Select all

/Q /c "pushd "%T" & "%T%M" "%P%N" "
This seems to work ok, but maybe I have broken something that you put in intentionally?

* Was the slash in "%T\%M" a typo? Does it do anything special? Removing it seemed to work ok...

* Is it necessary to split %P%N into %P%O.%E?

* The /Q switch seems to turn echo off so presumably @echo off is no longer needed
Post Reply