# Doskey alias command from a cmd shortcut not working

Opening a cmd prompt and manually issuing my custom doskey macro commands works fine, but I figured that I could save time by creating cmd shortcuts that invoke these commands automatically.

So, I created 2 cmd shortcuts that automatically run these doskey macros from the Target fields:

`%windir%\system32\cmd.exe /k m7`

and

`%windir%\system32\cmd.exe /k m50`

Running the shortcuts shows these error messages:

`'m5' is not recognized as an internal or external command`

and

`'m50' is not recognized as an internal or external command`

Image showing error message on top of the command prompt

Regular cmd commands, however, work when specified in the Target field:

`%windir%\system32\cmd.exe /k dir`

What do I have to do to make it work with a doskey alias command? By the way, I made sure that each shortcut runs as administrator. And all my doskey macros have been loaded into the registry for memory persistence between cmd sessions. Thanks.

The doskey cmd files:

alsias.cmd:

``````@echo off

doskey m7=C:\Bin\m7connect.cmd
doskey m50=C:\Bin\m50connect.cmd
``````

m7connect.cmd:

``````@echo off

timeout /t 1 /nobreak
scrcpy
``````

m50connect.cmd:

``````@echo off

timeout /t 1 /nobreak
scrcpy
``````
• Where do you see the advantage over simply creating a shortcut to connect.cmd's? – Furty Apr 25 '20 at 6:54
• @Furty Brilliant! That works. Can't believe I overlooked such an obvious solution. Thanks. – rajndev Apr 25 '20 at 16:14
• @Furty But, I'm still curious as to why a doskey alias as a parameter in the Target field of the shortcut doesn't work. Issuing the doskey command manually at the prompt after the cmd windows opens works though. Anyways, Thanks for your help. – rajndev Apr 25 '20 at 16:20

You can't call a DOSKEY macro in such way.

For proof, change your shortcut target to e.g.

``````%windir%\system32\cmd.exe /k "doskey /macros & m50"
``````

I'd guess that all macros are listed and the `'m50' is not recognized …` error occurs. However, you can successfully invoke a macro manually in the open `cmd` prompt window ( `m50`Enter)?

Read `CMD.EXE` as well (no option of a DOSKEY macro as `Command`):

``````Syntax
CMD [charset] [options]
CMD [charset] [options] [/C Command]
CMD [charset] [options] [/K Command]

Options
/C     Run Command and then terminate
This is useful for testing, to examine variables

Command : The command, program or batch script to be run.
``````

Solution: use the operational `cmd`s instead of their DOSKEY macro names in you shortcut target:

``````%windir%\system32\cmd.exe /k "C:\Bin\m7connect.cmd"
``````

and

``````%windir%\system32\cmd.exe /k "C:\Bin\m50connect.cmd"
``````

instead of `%windir%\system32\cmd.exe /k m7` and `%windir%\system32\cmd.exe /k m50` respectively.

• So there is no way of directly invoking a doskey macro command in the target field? Yes, with your modified target entry, it lists all the macros and the m50 not recognized error. And yes, manually entering the m7 or m50 commands works after the cmd window opens from the shortcut. For now, I'll just stick with the solution of directly pointing the target to the operational cmd files instead (m7connect.cmd and m50connect.cmd). Thanks. – rajndev Apr 25 '20 at 16:54