Code Gist: CMDRC
A .bashrc equivalent for Windows Command Prompt.
Add a REG_SZ or REG_EXPAND_SZ entry called AutoRun to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor] and enter the file path (%HOMEDRIVE%%HOMEPATH%\cmdrc.bat
). Do not use FOR /F loops, which recursively launch new cmd sessions.
@echo off
color 0B
echo:
echo %~dnpx0 automatically run by setting AutoRun in
echo [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor] with regedit.exe
echo:
where python >nul 2>nul
if %ERRORLEVEL% EQU 0 (
echo|set /p="LAN IP: "
python -c "import socket; print(socket.gethostbyname(socket.gethostname()), end='')"
)
echo.
echo Use d to enter Debug folder
echo Use b to run backup script
echo Use p to enter Python folder
echo Supported aliases: ls, pwd, ifconfig, clear
echo:
set DEBUGDIR=%HOMEDRIVE%%HOMEPATH%\Documents\Code\C\Project\Debug
set BACKUPSCRIPT=%HOMEDRIVE%%HOMEPATH%\Documents\Code\BackupScript\BackupScript.py
set PYTHONDIR=%HOMEDRIVE%%HOMEPATH%\Documents\Code\Python
doskey ls=dir
doskey pwd=echo %CD%
doskey ifconfig=ipconfig
doskey clear=cls
doskey d=cd /d %DEBUGDIR%
doskey b=python %BACKUPSCRIPT%
doskey p=cd /d %PYTHONDIR%