Aliases for Windows and Clink

Here is how to set aliases for the Windows command window and Clink if you’re using Clink.

First, create a cmd file somewhere to create your aliases using the doskey command. Mine looks like this:

@echo off
doskey np=notepad++.exe $*
doskey ls=dir $*
doskey ns=nslookup $*
doskey ip=ipconfig $*
doskey hosts=notepad++.exe C:\Windows\System32\drivers\etc\hosts
doskey aliases=notepad++.exe C:\Applis\clink\aliases.cmd

You can also use all available cmd commands and variables to customize your shell, like title, color, set PROMPT, …

Then, open your registry and go to the following key:
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
and add add a string value named AutoRun and valued with the absolute path of your aliases file.

That’s it, from now on, all your aliases will be loaded every time you start cmd or clink.

4 thoughts on “Aliases for Windows and Clink

  1. richaardvark

    The directions you have given here break the functionality of Clink because it replaces the original Autorun registry key that is required to launch Clink:

    “C:\Program Files (x86)\clink\clink.bat” inject –autorun –profile ~\clink

    Reply
    1. ChrisCran2003

      It’s possible to not broke clink :
      Create your own “.bat”, and finish it by the commande line set by clink in the registry.
      Then change the registry to replace set your .bat.

      Reply
    2. feasqo

      C:\Program Files (x86)\clink\clink.bat” inject –autorun –profile ~\clink && “absolute path of your aliases file”

      Reply
    3. omo pastor

      I got a solution.

      The batch file should be like this:

      np=notepad++.exe $* $T
      ns=nslookup $* $T
      ip=ipconfig $* $T
      hosts=notepad++.exe C:\Windows\System32\drivers\etc\hosts $T
      aliases=notepad++.exe C:\Applis\clink\aliases.cmd

      ‘$T’ is used to separate command when there is more than one.
      Info: https://ss64.com/nt/doskey.html

      In your registry, you can attach another script to ‘AutoRun’ using AND (&&) operator:

      “C:\Program Files (x86)\clink\clink.bat” inject –autorun –profile ~\clink && doskey.exe /macrofile=%USERPROFILE%.clink\aliases.cmd

      Source: https://github.com/mridgers/clink/issues/92#issuecomment-454873397

      Reply

Leave a Reply