When I install something like ffmpeg with winget, it sets permanent aliases for ffmpeg, ffplay, & ffprobe.
winget install gyan.ffmpegIt doesn’t look like it’s adding anything to my path environment variable. If I use the Set-Alias PowerShell utility, said alias is ephemeral, only lasting until the end of the current session. Eventually, I found that I can use my $profile to denote a list of aliases that instantiate every time I launch my shell.
Does winget do the same thing just with a different “profile” file? Is there a better way of doing this?

77 gold badges365 silver badges408 bronze badges
asked Sep 9, 2023 at 9:02

WinGet creates symlinks in this folder. These are then usable from any shell or Run prompt.
In my opinion, yes, this method is superior, because it is effective everywhere.
However, it only works with .exe files. If you need PowerShell-specific aliases (involving cmdlets or whatever), you must use PowerShell methods to create them permanently. $profile is the way to go.
answered Sep 15, 2023 at 8:17
Daniel B
9 gold badges128 silver badges176 bronze badges
From the post
How to create permanent PowerShell Aliases,
I quote the excellent
answer by Naigel :
To answer your question, you only have to create a
profile.ps1file
containing the code you want to be executed, that is:New-Alias Goto Set-Locationand save it in the proper path:
"$Home\Documents"(usuallyC:\Users\<yourname>\Documents): only your user will execute the code. This is the recommended location You
can quickly find your profile location by runningecho $profilein
PowerShell$PsHome(C:\Windows\System32\WindowsPowerShell\v1.0): every user will execute this codeIMPORTANT: remember you need to restart your PowerShell instances to apply the changes.
The paths are:
C:\Windows\System32\WindowsPowerShell\v1.0for the 64bit environment
C:\Windows\SysWow64\WindowsPowerShell\v1.0for the 32bit one (Yeah I know, the folder naming is counter-intuitive, but it’s
correct).
answered Sep 9, 2023 at 14:12

No, cmdlets like winget and other powershell modules install themselves inside your powershell modules folder. After you run import-module <name> that module’s commands can now be used. Commands are just functions.
function MyFunction()
{ write-host "MyFunction was executed."
}And save this in the path found before as a *.psm1 file where the * is replaced with anything you desire of course.
I haven’t found the need to actually write my own modules and I did end up just creating the functions inside my profile.ps1, so I’m not entirely sure what the location is to auto-load your modules, and if you need to add a .psd1 file next to the module for it to work.
This answer is just for you to know how else to do it, if using a profile.ps1 is out of the question.
answered Sep 9, 2023 at 15:38

10 gold badges101 silver badges146 bronze badges


