Run DOS-command from TC without a .bat

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
kodepr
Junior Member
Junior Member
Posts: 45
Joined: 2019-09-05, 08:13 UTC

Run DOS-command from TC without a .bat

Post by *kodepr »

Hi,

I have the code below in a .bat and I have a button in TC to run that .bat

Code: Select all

ipconfig /all
pause
I 'm trying to do the same thing (same "command" with a button in TC) but without the need for a .bat - unfortunately I can 't seem to make this work.
How can I do this, or is it impossible?

Thanks in advance!
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Run DOS-command from TC without a .bat

Post by *Stefan2 »

Use CMD or %comspec% as command and add /k as parameter into the command box. (use "CMD /?" in a DOS-window to read the help)
Add your wanted commands into the parameter box, using dos syntax to separate your commands.


Example
cmd: cmd /k
param: ipconfig /all & pause



"/k" and pause is doubled feature here, so you could maybe drop this pause command





 
kodepr
Junior Member
Junior Member
Posts: 45
Joined: 2019-09-05, 08:13 UTC

Re: Run DOS-command from TC without a .bat

Post by *kodepr »

Hi Stefan2,

Thanks!
"/k" and pause is doubled feature here, so you could maybe drop this pause command
Indeed, I don't notice a difference with or without the " & pause"

However, if I run the batch from my previous post, the DOS window closes after I hit ENTER.
But if I run your suggestion it doesn't close afterwards.

I read "CMD /?" and changed your suggestion to the code below which closes the DOS window afterwards.

Code: Select all

cmd: cmd /c
param: ipconfig /all & pause
I'm just curious to learn: is that the best way to change it or are there better solutions?

Thanks in advance!
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Run DOS-command from TC without a .bat

Post by *Stefan2 »

No, that's pretty fine.

-- The DOS windows closes because it is started w/o any "/k"-like switch, there you need the pause so you can read the output.
-- Since I told TC to execute the cmd with the /k-switch, that DOS windows stays open, and so you need no pause here and can still read the output.
-- "/k AND pause " reduplicates here both the same demand: "keep the window open", so you can drop pause here.



So in your case here, you can use both alternatives:

cmd: cmd /c
param: ipconfig /all & pause
Tooltip: execute and close, but here wait for the "pause"-key press, then close

cmd: cmd /k
param: ipconfig /all
Tooltip: execute and stay open, user must close the window himself




 
kodepr
Junior Member
Junior Member
Posts: 45
Joined: 2019-09-05, 08:13 UTC

Re: Run DOS-command from TC without a .bat

Post by *kodepr »

Thanks Stefan2,
All clear!
User avatar
MaxX
Power Member
Power Member
Posts: 1175
Joined: 2012-03-23, 18:15 UTC
Location: UA

Re: Run DOS-command from TC without a .bat

Post by *MaxX »

You can simply press Shift+Enter instead of Enter.
No need to use "/k", "pause", etc..
Ukrainian Total Commander Translator. Feedback and discuss.
Post Reply