Nom1fan

Batch Script For CMD Terminal Environment Aliases In Windows

May 6th, 2018
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :: Aliases version 1.0.0
  2. :: By Mor Merhav
  3.  
  4. :: This install script does the following steps:
  5. :: 1) Creates following file in %USERPROFILE%\\dev\\:
  6. ::      - aliases.cmd
  7. :: 2) Adds 'Autorun' value to registry: %USERPROFILE%\\dev\\aliases.cmd
  8. ::
  9. :: The result is that everything in aliases.cmd is run automatically each time a CMD terminal session is opened.
  10. :: You can now add to aliases.cmd whatever aliases/quick commands (using doskey) you wish!
  11.  
  12. mkdir %USERPROFILE%\\dev\\
  13.  
  14. @echo Creating 'aliases.cmd' file...
  15.  
  16. @echo off
  17. @echo @echo off > %USERPROFILE%\\dev\\aliases.cmd
  18. @echo echo Running with Aliases version "1.0.0" >> %USERPROFILE%\\dev\\aliases.cmd
  19. @echo doskey mci=mvn clean install -DskipTests >> %USERPROFILE%\\dev\\aliases.cmd
  20. @echo doskey mvn_versions=mvn versions:set -DnewVersion=$1 $T mvn versions:commit >> %USERPROFILE%\\dev\\aliases.cmd
  21. @echo doskey aliases=doskey /macros >> %USERPROFILE%\\dev\\aliases.cmd
  22.  
  23. @echo on
  24. @echo Creating registery value 'Autorun' ...
  25. @echo off
  26. start /wait reg add "HKCU\Software\Microsoft\Command Processor" /v Autorun /t REG_SZ /d %USERPROFILE%\\dev\\aliases.cmd
  27. if errorlevel 1 (
  28.    @echo on
  29.    echo Registry key creation failed with error: [%errorlevel%] from reg.exe
  30.    pause
  31.    exit /b %errorlevel%
  32. )
  33. @echo on
  34. @echo Aliases installation finished successfuly!
  35.  
  36. pause
Add Comment
Please, Sign In to add comment