i keep my doskey macros in a separate file with .macro file extension, and can load them using doskey /macrofile=macros.macro for the specific console session

i want to use windows os feature of file type association to load them without having to type the command (the executable's name or path) every time

for that reason i use two built-in cmd.exe commands:

assoc .macro=macro
ftype macro="doskey /macrofile=%1"

there's no error, but when i execute the file pop-up message appears, and basically it doesn't work

previously i tried to associate .reg files with reg import %1 and it worked, the problem here seems to be the equals sign in doskey's /macrofile= switch, i think the system can't handle it

i think, despite switches (/) and subcommands after the executable name can work with parameters, but = somehow fails to do so

so i'm asking for solutions :)

1 Answer 1


ftype splits its argument on "=" and provides no means to escape the second "=" character in the command. Fortunately this command just adds a simple registry setting, which you can add manually using reg in an elevated command prompt:

assoc .macro=macrofile
set k=HKLM\Software\Classes\macrofile\shell\open\command
set d="\"%SystemRoot%\system32\doskey.exe\" /macrofile=\"%1\""
reg add %k% /f /ve /d %d%

Or create a .reg file that can be imported with regedit or reg:

Windows Registry Editor Version 5.00





@="\"C:\\Windows\\system32\\doskey.exe\" /macrofile=\"%1\""


C:\>assoc .macro
C:\>ftype macrofile
macrofile="C:\Windows\system32\doskey.exe" /macrofile="%1"

C:\>doskey /macros:all

C:\>doskey /macros:all
    spam=echo spam!

  • thanks, for some reason it doesn't add the %1 part in the data field leaving the quotes empty, i added it manually in regedit, and if possible could you implement it in a reg file, it would be easier to import to the registry in a such way, i tried to do it but with no success (data didn't get added)
    – user373230
    Dec 23, 2014 at 17:05
  • The reg command I used gave exactly the result that I showed in the example via ftype macrofile, so it works fine for me in Windows 7. Are you using a different version?
    – Eryk Sun
    Dec 23, 2014 at 18:54

Your Answer

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