How to put bat file contents in a button?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
soc
Junior Member
Junior Member
Posts: 8
Joined: 2019-11-30, 12:48 UTC

How to put bat file contents in a button?

Post by *soc »

I have a one-line bat file (mybat.cmd) which I call from the command of a button in the button bar. The contents of the file is:

Code: Select all

@ECHO OFF && ECHO Creating %1... && FOR /F "usebackq tokens=1 delims=" %%i IN (`DIR "descript.ion" /A /O:NG /B /S /N`) DO (ECHO Adding %%i &&   ECHO. >> %1 &&   ECHO === %%i: >> %1 &&   TYPE "%%i" >> %1)
In the parameter field, I have put "merged-descript-ions.txt. This works fine.

But I could not find a way to put the code in the command line of the button. Can anyone help?

Thanks in advance.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6482
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: How to put bat file contents in a button?

Post by *Horst.Epp »

Command should be cmd.exe
Parameters are your batch line starting with /k
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: How to put bat file contents in a button?

Post by *Ovg »

I think that TS asking how to insert resulting file name (merged-descript-ions.txt) as a parameter. And I think that /c would be enough.
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
soc
Junior Member
Junior Member
Posts: 8
Joined: 2019-11-30, 12:48 UTC

Re: How to put bat file contents in a button?

Post by *soc »

When I put in bat file in the button, like below, it works fine. (It merges all descrpt.ion files into one txt file):

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe /c c:\Test\mybat.cmd
merged-comments.txt
C:\Windows\System32\imageres.dll
Merge descript.ion files


-1
But when I replace the bat content for the name of the bat file, as in the button below, it does not work anymore!

Code: Select all

TOTALCMD#BAR#DATA
cmd.exe /c @ECHO OFF && ECHO Creating %1... && FOR /F "usebackq tokens=1 delims=" %%i IN (`DIR "descript.ion" /A /O:NG /B /S /N`) DO (ECHO Adding %%i &&   ECHO. >> %1 &&   ECHO === %%i: >> %1 &&   TYPE "%%i" >> %1)
merged-comments.txt
C:\Windows\System32\imageres.dll
Merge descript.ion files


-1
Does the bat file code needs any modification obscure to me?
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: How to put bat file contents in a button?

Post by *Ovg »

2soc
Change %1 to your actual filename, change %% to %

Code: Select all

TOTALCMD#BAR#DATA
cmd /c @ECHO OFF && ECHO Creating qqq.txt... && FOR /F "usebackq tokens=1 delims=" %i IN (`DIR "descript.ion" /A /O:NG /B /S /N`) DO (ECHO Adding %i && ECHO. >> qqq.txt && ECHO === %i: >> qqq.txt && TYPE "%i" >> qqq.txt)

C:\Windows\System32\imageres.dll
Merge descript.ion files


-1
Change all occurrences of qqq.txt to your actual filename
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
soc
Junior Member
Junior Member
Posts: 8
Joined: 2019-11-30, 12:48 UTC

Re: How to put bat file contents in a button?

Post by *soc »

Ah! It works like magic! Thanks Ovg.

I also tried transferring the whole part after cmd /c to the Parameter field (I replaced all % by %%). It still works.

What I did not understand though, what why %1 worked in the bat file, but does not work in the button bar.
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: How to put bat file contents in a button?

Post by *Ovg »

%1 is replaced by command processor with the first parameter passed to cmd file, TC isn't a command processor and button's command isn't a cmd file
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
soc
Junior Member
Junior Member
Posts: 8
Joined: 2019-11-30, 12:48 UTC

Re: How to put bat file contents in a button?

Post by *soc »

Thanks, OVG. I thought all one-line bat files could be transferred to button. Probably, for most bat files, it is better to call the file from the button bar. But then we lose the convenience of the parameter field of the button.
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: How to put bat file contents in a button?

Post by *Ovg »

2soc
Take a look at http://totalcmd.net/plugring/askparam.html - maybe is is what you need. I didn't use this utility yet
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
Post Reply