batch-filecmddoskey

Macro comands not excuteing in batch file


i am currently in the process of a project and i want to use DOSKEY commands i have in a bat file, for example run program of change direcorties theses commands all work on in my CLI. just wondering if theres a way to commands like note =notepad.ext 1$("useing this just as a simple example") to run in the bat file ,does the file need permissions ,what the process to have my bat files run the commands i make?

i tried multiple command and topics and looked at chatgpt but the problem wasnt really that well described


Solution

  • Doskey macros can't be used/executed from batch files.

    They can only be executed, when they are typed by the keyboard.

    C:\Users> doskey mymacro=echo hello
    C:\Users> mymacro
    hello
    C:\Users> echo mymacro | cmd /k
    'mymacro' is not recognized as an internal or external command, operable program or batch file.
    

    A workaround is to use batch files instead of doskey macros.

    note.bat

    @echo off
    notepad "%~1"