An easy method to set command line parameters, user preferences, environment settings and aliases in the windows command prompt analogous to .bashrc
/ .bash_profile
in linux. People can add their own settings to add funcitonality. The objective of the batch file is to provides a template for the same. However, the important step is the registry edit which allows system-wide changes.
- Set aliases for different commands.
- Run commands like
gcc
/g++
or other executables with whatever options you want without specifying those options everytime you run the program. - Launch different apps and programs using aliases.
- Set environment variables.
- Download the
cmd_properties.bat
file and store it in a secure location likeC:\Users\username\AppData
. - Add a new key to the Windows Registry using
regedit
command atHKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor
with the following properties:- value(Name) -
AutoRun
- type -
REG_EXPAND_SZ
- data -
"C:\Users\username\AppData\cmd_properties.bat"
(or wherever the file is saved)
- value(Name) -
- The file can be saved with whatever name you want but the file type or the file extension should be
.bat
or.cmd
. - If the file is moved to a different location, you have to edit the key data in registry to reflect the changes.
- This method ensures that the changes persist no matter where you launch the command prompt from and even after closing the current session.
Additional Resources: Batch file commands