当我尝试这个时(它使用.bat 文件安装窗口商店、计算器、照片和便笺):
Powershell "Get-AppXPackage -AllUsers *WindowsStore* | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"
Powershell "Get-AppxPackage -AllUsers *windowscalculator* | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}"
Powershell "Get-AppxPackage -AllUsers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"
Powershell "Get-AppxPackage –AllUsers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"
Powershell 向我返回一个错误:Positional parameter cannot be found that accepts argument « \AppXManifest.xml »
我也试过:
Get-AppXPackage *WindowsStore* -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"
Get-AppxPackage -AllUsers *windowscalculator* | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"
Get-AppxPackage -AllUsers Microsoft.Windows.Photos | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"
Get-AppxPackage -AllUsers Microsoft.MicrosoftStickyNotes | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}"
它返回:'get-appxpackage' is not recognized as an internal or external command, operable program or batch file
我在Powershell 脚本 (.ps1)中尝试了上述方法,它运行良好。
问题是我想将此代码实现到现有的 .bat 脚本中。我不能只是将我的 .bat 转换为 .ps1,因为我需要在 powershell 中重新编写它,而我根本没有技能。
问候