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


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

Running the shortcuts shows these error messages:

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


'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:


@echo off

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


@echo off

adb disconnect
adb connect
timeout /t 1 /nobreak


@echo off

adb disconnect
adb connect
timeout /t 1 /nobreak
  • 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 ( m50Enter)?

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

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

    /C     Run Command and then terminate
    /K     Run Command and then return to the CMD prompt.
           This is useful for testing, to examine variables

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

Solution: use the operational cmds instead of their DOSKEY macro names in you shortcut target:

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


%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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.