由于神州网信政府版Windows的安全性设置,无法安装应用商店,无法通过下载Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle后安装,有大神制作了安装脚本https://github.com/asheroto/winget-install/releases,下载脚本后通过 Windows PowerShell 命令窗口成功安装:
PS G:\Downloads> .\winget-install.ps1
.\winget-install.ps1 : 无法加载文件 G:\Downloads\winget-install.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 h
ttps:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ .\winget-install.ps1
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS G:\Downloads> get-executionpolicy
Restricted
PS G:\Downloads> set-executionpolicy remotesigned
执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): y
PS G:\Downloads> .\winget-install.ps1
是否要运行来自此不可信发布者的软件?
文件 G:\Downloads\winget-install.ps1 由 CN=Asher Solutions Inc, O=Asher Solutions Inc, L=Muskogee, S=Oklahoma, C=US
发布,该文件对于你的系统是不可信的。请只运行来自可信发布者的脚本。
[V] 从不运行(V) [D] 不运行(D) [R] 运行一次(R) [A] 始终运行(A) [?] 帮助 (默认值为“D”): y
[V] 从不运行(V) [D] 不运行(D) [R] 运行一次(R) [A] 始终运行(A) [?] 帮助 (默认值为“D”):
PS G:\Downloads> .\winget-install.ps1
是否要运行来自此不可信发布者的软件?
文件 G:\Downloads\winget-install.ps1 由 CN=Asher Solutions Inc, O=Asher Solutions Inc, L=Muskogee, S=Oklahoma, C=US
发布,该文件对于你的系统是不可信的。请只运行来自可信发布者的脚本。
[V] 从不运行(V) [D] 不运行(D) [R] 运行一次(R) [A] 始终运行(A) [?] 帮助 (默认值为“D”): r
winget-install 5.0.5
To check for updates, run winget-install -CheckForUpdate
To delay script exit, run winget-install -Wait
To force script pausing after execution, run winget-install -NoExit
##########
# winget #
##########
Installing Microsoft.WinGet.Client module...
Installing winget (this takes a minute or two)...
############
# Complete #
############
winget installed successfully.
Checking if winget is installed and working...
winget is installed and working. You can go ahead and use it.
PS G:\Downloads>
使用winget安装软件:
H:\V.0.2.7>winget install Ninja-build.Ninja
“msstore”源要求在使用前查看以下协议。
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
源要求将当前计算机的 2 个字母的地理区域发送到后端服务才能正常工作,(例如"US")。
是否同意所有源协议条款?
[Y] 是 [N] 否: y
已找到 ninja [Ninja-build.Ninja] 版本 1.12.1
此应用程序由其所有者授权给你。
Microsoft 对第三方程序包概不负责,也不向第三方程序包授予任何许可证。
正在下载 https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-win.zip
██████████████████████████████ 268 KB / 268 KB
已成功验证安装程序哈希
正在提取存档...
已成功提取存档
正在启动程序包安装...
已修改路径环境变量;重启 shell 以使用新值。
添加了命令行别名: "ninja"
已成功安装
将软件安装了到路径:C:\Users\Monday\AppData\Local\Microsoft\WinGet\Packages\Ninja-build.Ninja_Microsoft.Winget.Source_8wekyb3d8bbwe 中,并在环境变量path中增加了该路径。