当我从bat文件运行Powershell输出时,我需要看到它。 bat 文件暂停没有问题,但电源外壳执行并在屏幕上闪烁并在我读取电源外壳错误之前关闭。 如何暂停电源外壳输出以便我可以读取它。
蝙蝠文件删除包FitBit.bat
@ECHO Off
PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs} | Wait-Process"
@PAUSE
Powershell file RemovePackagesFitBit.PS1
Get-AppxPackage -allusers *fitbit* | Remove-AppxPackage
在 Windows 10 中运行此函数
只需在需要时在脚本中插入暂停:
$Package = Get-AppxPackage -allusers -Name fitbit
Pause
$Packasge | Remove-AppxPackage
Pause
我无法在暂停时看到错误,因此我以这种方式将所有输出记录到文件中: 我把它放在脚本的开头:
$Logfile = "C:TempFix-Sysprep.log"
If (Test-Path $Logfile)
{
Remove-item -path $Logfile
}
Start-Transcript -Path $Logfile -Append
我把它放在脚本的末尾:
Stop-Transcript