batch-fileregistrydoskey

Add single doskey command - Windows Registry


I'm working on a batch file, and I need to add this entry:

doskey wfreerdp="C:\Program Files\wfreerdp\wfreerdp.exe" $*

to this regkey:

HKCU\Software\Microsoft\Command Processor

I played with the options of reg add, but I simply cannot get it to work.

I know it should be something like:

reg add "HKCU\Software\Microsoft\Command Processor" /v doskey wfreerdp = "C:\Program Files\wfreerdp\wfreerdp.exe" $*

but I don't which one and how to use the /t, /S, /d & /f flags.

If I manually add the entry:

doskey wfreerdp = "C:\Program Files\wfreerdp\wfreerdp.exe" $*

it works perfectly.

Alternativelly I tried creating the C:\bat\macros.doskey file, containing the doskey command:

doskey wfreerdp = "C:\Program Files\wfreerdp\wfreerdp.exe" $*

and the following in the batch file:

reg add "HKCU\Software\Microsoft\Command Processor" /v Autorun /d "doskey /macrofile=\"c:\bat\macros.doskey\"" /f

No success.

Any tips?


Solution

  • If you are trying to add the doskey command to your Command Prompt's AutoRun so that it will run every time you open cmd.exe, then you would need to run the following:

    reg add "HKCU\Software\Microsoft\Command Processor" /v "AutoRun" /d "doskey wfreerdp = \"C:\Program Files\wfreerdp\wfreerdp.exe\" $*"
    

    Let's break this down: