Powershell's $profile analog for regular windows command line (cmd.exe)

cmd, powershell

Solution

There is no real equivalent to PowerShell's `$profile` for `CMD`. However, some customization can be done with an AutoRun script. Add a new `REG_SZ` (or `REG_EXPAND_SZ`) value `AutoRun` with the path to your script to `[HKCU\Software\Microsoft\Command Processor]`, e.g. like this:

reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun /t REG_SZ /d "C:\path\to\your\init.cmd"

I normally use an `init.cmd` like this:

@echo off
doskey /insert /macrofile=%USERPROFILE%\macro.def

with `macro.def` containing my aliases:

.="%SystemRoot%\explorer.exe" /e,.
..=cd ..
ls=dir /d $*
ll=dir /x $*

Problem

Powershell's $profile is very convenient to add frequently used commands. How can I do the same in cmd.exe?

Original source