Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to alias an executable using Powershell permanently?

Tags:

powershell

Creating and running an alias in a current Powershell session works,

Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> new-item alias:eadt -value "C:\adt-bundle-windows-x86_64-20140702\eclipse\eclipse.exe"

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Alias           eadt -> eclipse.exe


PS C:\Windows\system32> eadt

but fails in a new session:

PS C:\Windows\system32> eadt
eadt : The term 'eadt' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ eadt
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (eadt:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Windows\system32>
like image 746
030 Avatar asked Oct 17 '25 03:10

030


1 Answers

You should save your alias in your profile (like in .bashrc in Linux). Hava a look to About_profile to choose your one.

$Profile var gives you the path to your profile file.

It exists 4 different profil files given by :

$profile.AllUsersAllHosts
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

$profile.AllUsersCurrentHost
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1

$profile.CurrentUserAllHosts
C:\Users\JPB\Documents\WindowsPowerShell\profile.ps1

$profile.CurrentUserCurrentHost
C:\Users\JPB\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
like image 107
JPBlanc Avatar answered Oct 18 '25 22:10

JPBlanc