4

I have multiple doskeys defined in following fashion:

doskey ll=dir $*
doskey grep=findstr $*
doskey make=mingw32-make $*

I want to use them in conjunction in one-line commands such as:

ll | grep my_folder

or

make && make install

But after first pipe/not/and operator, the doskeys no longer appear to exist since the cmd won't recognize the commands. For example, while single make command works, calling echo hello && make will tell me the make is not recognized as a command.

Is there a way to preserve the doskey context so I can chain them together as written above?

Also, the same issue applies to running batch files using the doskeys, is there a way to preserve the context for that too?

I've heard about the $T argument of doskey, but I am not quite sure if I understand it.

Thanks for help in advance

doomista
  • 501
  • 2
  • 10
  • 2
    DOSKEY is only for interactive use. It does not work in a batch file script. https://stackoverflow.com/questions/36616151/doskey-alias-does-not-work-in-batch-script-windows-7 – lit Sep 07 '18 at 11:11
  • This looks like it works, but it somewhat defeats the point of having short commands. `ll | cmd.exe /C findstr "new"` – lit Sep 07 '18 at 14:10
  • @lit thanks for clarification with batch files, however using redirection to new cmd instance does not solve anything as the newly executed cmd does not inherit doskey settings – doomista Sep 07 '18 at 17:23

1 Answers1

5

I had a similar issue...
Following macro was not handling the section after the | character:

doskey system=systeminfo | findstr /C:"OS"

But, the following did:

doskey system=systeminfo $B findstr /C:"OS"

So, looks like doskey's pipe symbol is $B.

DanyGee
  • 93
  • 1
  • 7