Replacing an Alias
To replace an alias in a batch environment, we can simply edit the shortcut name to the command we want to replace with.
doskey [shortcut command] = [new commands]
We can simply redefine the shortcut alias to the new command just as we do with variables in programming.
Note: You need to use the doskey if you are writing your aliases in the file or a batch script, but if you are creating aliases just in the CMD/Powershell instances then you don’t need to write the keyword doskey in the command.
For example, we can write the cdoc alias again as follows:
We have redefined the alias to a new command and it can now work with the latest command it was changed to.
Batch Script – Aliases
Be it Linux, macOS, or Windows, we sometimes need to use the terminal or the command line to perform certain commands. If in such situations, we find ourselves repeating a few long commands we can use an alias to save time and make it easier. In windows, we can create an alias as a batch command from the command prompt or the Powershell. We will see how to create and work with an alias in Batch scripting.
Contact Us