据说,在每个 Microsoft 补丁安装后停止 trustinstaller.exe 任务会稍微加快安装过程。有没有办法隐藏终止该任务的输出?现在它输出到cmd窗口“成功:任务TrustedInstaller.exe终止...”,我不想看到这一点,因为最终用户不需要被它迷惑。它似乎没有可用的 /quiet 或 /q 开关。
一般来说,手动安装更新有更好的方法吗?我喜欢买咖啡!!预先感谢您...
这是我正在使用的简短脚本:
@echo off
echo Microsoft security updates being installed!!!
:=================================================================
::sc config wuauserv start= demand
::sc start wuauserv
:=================================================================
echo.
echo Installation may take several minutes...
Pushd %~dp0
:=================================================================
:----------------------- Required Patches ------------------------
echo.
echo Installing KB5017396 Servicing Stack Update...
wusa.exe windows10.0-kb5017396-x64_8db1a993e6115cf3b92d0159f562861ab16ee88d.msu /quiet /norestart
cmd.exe /C TaskKill /IM TrustedInstaller.exe /F
echo.
echo Installing KB5018411 Cumulative Update...(this one takes the longest)
wusa.exe windows10.0-kb5018411-x64_0ce64987a6675227941fadd950019e447d60ba03.msu /quiet /norestart
cmd.exe /C TaskKill /IM TrustedInstaller.exe /F
echo.
echo Installing KB890830 Windows Malicious Software Removal Tool...
wusa.exe windows-kb890830-x64-v5.109_7bafbdf130e5ccd23c002984c7481286dc173072.exe /quiet /norestart
echo Restart this computer in order to apply updates.
echo.
PAUSE
:=================================================================
::sc stop wuauserv
::sc config wuauserv start= disabled
:=================================================================
:=================================================================
exit
将
>NUL 2>NUL
放在最开始/结束处(后者有时取决于命令本身)它应该适用于几乎所有操作系统。
可能存在其他形式或简短的形式,但其中一些给我带来了错误(例如批次意外关闭)。
该命令意味着当前命令行引起的所有输出都应该隐藏在 cmd/batch 中。
这是在cmd窗口中适合我的解决方案
taskkill /f /t /im 'test_program.exe' 1>nul 2>&1
顺便说一句,我发现当使用Powershell(版本5.1)而不是cmd窗口时,
nul
短语必须替换为$null
短语,否则会出现错误。taskkill /f /t /im "test_program.exe" 1>$null 2>&1
Windows 中似乎有标准流,其编号方式与 Linux 中相同
0: stdin
1: stdout
2: stderr
2>&1
将命令的标准错误输出重定向到命令的标准输出1>nul
或 1>$null
导致命令的标准输出被抑制。这与在 Linux 中重定向到 /dev/null
类似