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?
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:
From the documentation at cmd /?
:
If /D was NOT specified on the command line, then when CMD.EXE starts, it looks for the following REG_SZ/REG_EXPAND_SZ registry variables, and if either or both are present, they are executed first. HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun and/or HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
You already know you're placing the key into HKEY_CURRENT_USER\Software\Microsoft\Command Processor
.
/v
switch specifies the value name to add/modify, which in this case is the AutoRun
key./d
switch specifies what that key should contain, which in this case is the doskey
command."
), you would need to escape them so they are not processed by the command line (\"
).