COMMAND Prompt AutoRun,  DOSKey,  Macros

If you want a defined set of commands to run every time you start a command prompt, the best way to achieve that would be to specify an init script in the AutoRun registry value. Create it like this (an expandable string value allows you to use environment variables like %USERPROFILE%):

reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun /t REG_EXPAND_SZ /d "%"USERPROFILE"%\init.cmd" /f

Then create a file init.cmd in your profile folder:

@echo off

command_A
command_B
...
cls

To remove these changes, delete the registry key:

reg delete "HKCU\Software\Microsoft\Command Processor" /v AutoRun

Example

@echo off

REM cls

REM c:\windows\system32\reg.exe add HKCU\Console /v CursorSize /d 100 /F

ECHO [96m,---.                        

ECHO [96m^|    ,---.,---..   .,---.,---.

ECHO [96m^|    ^|    ^|   ^|^|   ^|`---.^|---'

ECHO [96m`---'`    `---'`---'`---'`---'

REM ECHO WELCOME

REM  ALT+0+2+7+[

set PROMPT=^[[36m$d $t$H$H$H$H$H$H - %computername% - %username%^^[[92m$_$p$g^[[0m

title %username%

ECHO.

doskey ..=cd..

doskey c=cls

doskey psexec="\\cswis001\il\PsTools\psexec.exe " $* /accepteula

doskey psgetsid="\\cswis001\il\PsTools\psgetsid.exe" $* /accepteula

doskey sid="\\cswis001\il\PsTools\psgetsid.exe" $* /accepteula

doskey psinfo="\\cswis001\il\PsTools\Psinfo.exe" $* /accepteula

doskey pskill="\\cswis001\il\PsTools\pskill.exe" $* /accepteula

doskey psloggedon="\\cswis001\il\PsTools\psloggedon.exe" $* /accepteula

doskey n="c:\Program Files (x86)\Notepad++\notepad++.exe" $*

REM doskey df=C:\Windows\System32\cscript.exe "\\cswis001\il\CrouseScripts\tools\disksize.vbs" $*

doskey df="\\cswis001\il\CrouseScripts\tools\conDiskSpace.exe" $*

doskey bye=C:\Windows\System32\shutdown.exe /l

REM doskey reboot=\\cswis001\il\PsTools\psexec.exe /accepteula \\$1 shutdown /r /f /t 0 /c "Rebooted by Doskey"

REM doskey shutdown=\\cswis001\il\PsTools\psexec.exe /accepteula \\$1 shutdown /s /f /t 0 /c "Shutdown by Doskey"

doskey windirstat="\\cswis001\il\WinDirStat\windirstat.exe"

doskey fax=\\cswis001\il\CrouseScripts\rfax_state_query.cmd

doskey enum="c:\windows\syswow64\cscript.exe" //nologo "\\cswis001\il\CrouseScripts\enumGroupsForAD_Recursive.vbs" $*

doskey encounter=c:\windows\syswow64\cscript.exe  //nologo \\cswis001\il\EncounterExtractor\EncounterExtractor.vbs $*

doskey lastreboot=WEVTUtil query-events System /count:1 /rd:true /format:text /q:"Event[System[(EventID=1074)]]" /r:$*

doskey uptime=\\cswis001\il\CrouseScripts\uptime.exe $*

doskey serverstats="\\cswis001\il\CrouseScripts\serverstats.exe" $*

doskey rdsmonitor=\\cswis001\il\CrouseScripts\rdsmonitor.exe $*

doskey clear=\\cswis001\il\CrouseScripts\conRunRemoteProcess.exe $*

doskey errorcodes=\\cswis001\il\CrouseScripts\errorcodes.exe $*

doskey SQLVersions=\\cswis001\il\CrouseScripts\SQLVersions.exe $*

doskey weather=\\cswis001\il\CrouseScripts\weather.exe $*

doskey tix=\\cswis001\il\CrouseScripts\conSDtickets.exe $*

doskey ram=tasklist /s $*^|sort /+64n /rev^|FindStr /V "Image Name"^|FindStr /V "====="^|find /N " "^|Findstr /r \[[0-9]\]

doskey ls=dir $*

doskey qs=query session /server:$*

doskey qu=query user /server:$*

http://stackoverflow.com/questions/17404165/how-to-run-a-command-on-command-prompt-startup-in-windows

https://serverfault.com/questions/490841/how-to-display-the-first-n-lines-of-a-command-output-in-windows-the-equivalent

https://superuser.com/questions/247548/doskey-for-compound-command

https://stackoverflow.com/questions/23511172/windows-findstr-command-exclude-results-containing-particular-string