How to create aliases in windows 10

Updated: 12th December 2022
Tags: windows alias

Firstly, you need to have a folder with your scripts and add this folder to Environment path (PC properties → advanced → Environment variables → Edit path → add path to your folder)

Method 1 (bat file)

create bat file with command to perform. Here sample content of a.bat

php artisan tinker

It will work anywhere - both cmd and powershell. One downside it will annoy you with prompt Terminate batch job (Y/N)? on ctr+c.

Method 2 (ps1 file)

create ps1 file with command to perform. Here sample content of a.ps1

Invoke-Expression 'php artisan tinker'

It will work only in powershell. But it doesn't prompt Terminate batch job (Y/N)? which is a relief.