cmder icon indicating copy to clipboard operation
cmder copied to clipboard

Aliases don't work in batch files

Open Razor-13 opened this issue 9 years ago • 6 comments

Is there any way to make aliases work in batch files?

Razor-13 avatar Apr 01 '17 06:04 Razor-13

Using separators like & also doesn't work to execute commands in order, e.g. ytquality=youtube-dl -F $* with input ytquality https://www.youtube.com/watch?v=BaW_jenozKc & ytquality https://www.youtube.com/watch?v=BaW_jenozKc it recognizes the first alias then the second either doesn't work or isn't recognized by trying also $1, "$1 $T", "$* $T"

What stems from this though is if there is any way to make cmder just execute a list of commands in order outside of a bat file

Razor-13 avatar Apr 02 '17 19:04 Razor-13

@Razor-13 Perhaps your issue is a duplicate of #1325?

jrappen avatar Apr 06 '17 20:04 jrappen

@jrappen I'm on Windows 7 x64 SP1 and the aliases do work, I'm talking about them working in batch files or after operators (&, &&, ||, etc)

Razor-13 avatar Apr 07 '17 00:04 Razor-13

Assuming your shell is cmd.exe, then aliases are a wrapper around the doskey command and you are limited to how doskey macros work -- what you are trying to do is not supported.

From the doskey documentation:

To run a macro, type the macro name starting at the first position on the command line ... You cannot run a doskey macro from a batch program.

So macros cannot be used after another command (i.e. after &, &&, ||) and cannot be used from batch files.

You may want to move those aliased commands to their own bat files on your PATH -- that way you can still use them from the shell, but also have more flexibility in how they can be called.

glucas avatar Apr 24 '17 20:04 glucas

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs. Thank you for your contribution.

stale[bot] avatar May 25 '19 10:05 stale[bot]

This issue has been automatically closed due to it not having any activity since it was marked as stale. Thank you for your contribution.

stale[bot] avatar Jun 01 '19 10:06 stale[bot]