asheroto / winget-install

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2019/2022.
https://bit.ly/winget-install
GNU General Public License v3.0
272 stars 33 forks source link

[Feature request]: Initializing winget without rebooting #21

Closed uffemcev closed 12 months ago

uffemcev commented 12 months ago

What You Are Seeing?

Hello, it's me again! :) After running the script on a freshly installed system I get this result:

Log Checking if winget is installed and working... ПРЕДУПРЕЖДЕНИЕ: winget is installed but is not detected as a command. Try using winget now. If it doesn't work, wait about 1 minute and try again (it is sometimes delayed). Also try restarting your computer. ПРЕДУПРЕЖДЕНИЕ: If you restart your computer and the command still isn't recognized, please read the Troubleshooting section of the README: https://github.com/asheroto/winget-install#troubleshooting ПРЕДУПРЕЖДЕНИЕ: Make sure you have the latest version of the script by running this command: winget-install -CheckForUpdate PS C:\Users\uffemcev> winget winget : Имя "winget" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличие и правильность пути, после чего повторите попытку. строка:1 знак:1 \+ winget \+ ~~~~~~ \+ CategoryInfo : ObjectNotFound: (winget:String) [], CommandNotFoundException \+ FullyQualifiedErrorId : CommandNotFoundException

Even after installation via a script winget is still not initialized in the system. The problem can be solved by restarting the PC, but there is another way to solve this. Microsoft suggests using this command: Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe

After this the winget is ready for work instantly. So what do you think about this?

System Details

Script verson 3.0.1 Windows 22H2 UAC disable Powershell 5.1 Run as administrator

asheroto commented 12 months ago

Hey again!

Just want to confirm... so restarting the computer fixes the issue, yes?

But if we run this command instead, no restart is required?

Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
uffemcev commented 12 months ago

Yes it is.

asheroto commented 12 months ago

Cool. Have you confirmed this works on your end? Meaning have you run the command yourself and seen winget start working afterwards?

If on Windows 10 I can have it execute that command and then that should ensure winget runs.

uffemcev commented 12 months ago

Yes exactly. Now I will reinstall the system again and upload the full log.

uffemcev commented 12 months ago

Sorry for russian language in logs. I confirm that this command initializes winget after using your script on freshly installed windows 11 22H2. No reboot is required. No account logout is required.

Log Windows PowerShell (C) Корпорация Майкрософт (Microsoft Corporation). Все права защищены. Установите последнюю версию PowerShell для новых функций и улучшения! https://aka.ms/PSWindows PS C:\Users\uffemcev> winget winget : Имя "winget" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличие и правильность пути, после чего повторите попытку. строка:1 знак:1 \+ winget \+ ~~~~~~ \+ CategoryInfo : ObjectNotFound: (winget:String) [], CommandNotFoundException \+FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\uffemcev> &([ScriptBlock]::Create((irm https://raw.githubusercontent.com/asheroto/winget-install/master/winget-install.ps1))) winget-install 3.0.1 To check for updates, run winget-install -CheckForUpdate \########################################## \# Downloading & installing x64 VCLibs... # \########################################## Installing x64 VCLibs... VCLibs installed successfully. \########################################### \# Downloading & installing x64 UI.Xaml... # \########################################### Installing x64 UI.Xaml... ПРЕДУПРЕЖДЕНИЕ: Error when trying to download or install UI.Xaml. Trying alternate method... Downloading UI.Xaml... Extracting... Installing x64 UI.Xaml... UI.Xaml installed successfully. \###################################### \# Downloading & installing winget... # \###################################### Retrieving download URL for winget from GitHub... Downloading winget... Downloading license... Installing winget... winget installed successfully. \################################################################################################# \# Checking and adding WindowsApps directory to PATH variable for current user if not present... # \################################################################################################# Adding PATH variable for Machine... PATH variable already present for User, skipping. \########################## \# Installation complete! # \########################## Checking if winget is installed and working... ПРЕДУПРЕЖДЕНИЕ: winget is installed but is not detected as a command. Try using winget now. If it doesn't work, wait about 1 minute and try again (it is sometimes delayed). Also try restarting your computer. ПРЕДУПРЕЖДЕНИЕ: If you restart your computer and the command still isn't recognized, please read the Troubleshooting section of the README: https://github.com/asheroto/winget-install#troubleshooting ПРЕДУПРЕЖДЕНИЕ: Make sure you have the latest version of the script by running this command: winget-install -CheckForUpdate PS C:\Users\uffemcev> winget winget : Имя "winget" не распознано как имя командлета, функции, файла сценария или выполняемой программы. Проверьте правильность написания имени, а также наличие и правильность пути, после чего повторите попытку. строка:1 знак:1 \+ winget \+ ~~~~~~ \+ CategoryInfo : ObjectNotFound: (winget:String) [], CommandNotFoundException \+ FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\uffemcev> Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe PS C:\Users\uffemcev> winget Диспетчер пакетов Windows версии 1.6.2771 (с) Корпорация Майкрософт (Microsoft Corporation). Все права защищены. Программа командной строки winget дает возможность устанавливать приложения и другие пакеты из командной строки. использование: winget [<команда>] [<параметры>] Применимы следующие команды: install Установка указанного пакета show Показывает сведения о пакете source Управление источниками пакетов search Поиск и отображение базовых сведений о пакетах list Отображать установленные пакеты upgrade Отображает и выполняет доступные обновления uninstall Удаление указанного пакета hash Вспомогательное приложение для хэширования файлов установщика validate Утверждает файл манифеста settings Открыть параметры или настроить параметры администратора features Показывает состояние экспериментальных компонентов export Экспортирует список установленных пакетов import Устанавливает все пакеты в файле pin Управление закреплениями пакетов configure Настройка системы в нужное состояние download Скачивание установщика из указанного пакета Для более подробной информации о конкретной команде передайте ей аргумент справки. [-?]
asheroto commented 12 months ago

Excellent. I will take a look at this in the next few days to implement. I appreciate you pointing this out!

asheroto commented 12 months ago

Hey there, just added it. You should now see this when running. Can you please confirm this works in version 3.0.2?

image

uffemcev commented 12 months ago

Hello! Thanks for this, but this command works in Windows 11 too, my system is 11, not 10. Sorry I didn't say this earlier. Perhaps it makes sense to check not only for 10, but also for 11.

uffemcev commented 12 months ago

Something like that:

example # Run command to register winget $osVersion = Get-OSInfo $osType = $osVersion.Type if ($osType -eq "Workstation") { Write-Output "Registering winget..." try { Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe } catch { Write-Warning "Unable to register winget. Try running the following command: Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe" } }
asheroto commented 12 months ago

Ah understood. I've got it fixed in version 3.1.1.

Also I added this method of use: https://github.com/asheroto/winget-install#method-2---one-line-command-runs-immediately

asheroto commented 12 months ago

Going to close this issue, let me know if you think we need to reopen it. I think it should be working now for you on all OS versions.

uffemcev commented 12 months ago

I see the changes, thank you very much! Everything works as it should.

asheroto commented 12 months ago

Thanks for letting me know about that, it should help others!