-
-
Save phyoewaipaing/389928fa29dc8ede3798472aebdf7de6 to your computer and use it in GitHub Desktop.
Function to add Winget Executable Path to the current powershell session variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Add-WinGetPath { | |
$WinGetPath = (Get-ChildItem -Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller*_x64*\winget.exe").DirectoryName | |
If (-Not(($Env:Path -split ';') -contains $WinGetPath)) | |
{ | |
If ($env:path -match ";$") | |
{ | |
$env:path += $WinGetPath + ";" | |
} | |
else | |
{ | |
$env:path += ";" + $WinGetPath + ";" | |
} | |
write-host "Winget path $WinGetPath added to environment variable" | |
} | |
else | |
{ | |
write-host "Winget path already exists in registry." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment