使用 wmic 卸载在同一行写入 "Uninstalling" 和 "Done" 的批处理文件

Batch file to write "Uninstalling" and "Done" on the same line with a wmic uninstall

我想使用 wmic 方法通过 bathc 卸载程序。我想要一条消息说 "uninstalling...",然后是 "done",而不是转到下一行。下面是我正在尝试的代码,但它不起作用:

set /p a=Uninstalling XXXXX...........<nul
wmic product where name="XXXXXXX" call uninstall >null<nul
set /p a=Done<nul
echo.

如有任何帮助,我们将不胜感激!

以下使用了发布到 DosTips by Jeb 的技巧。我相信这就是你所追求的。

@echo off
setLocal enableDelayedExpansion
copy nul sub.tmp /a > nul
for /F %%a in (sub.tmp) DO set "sub=%%a"
del sub.tmp

call :echoWithoutLinefeed "Uninstalling XXXXX..........."
wmic product where name="XXXXXXX" call uninstall >null
call :echoWithoutLinefeed " Done"

:echoWithoutLinefeed
> txt.tmp (echo(%~1!sub!)
copy txt.tmp /a txt2.tmp /b > nul
type txt2.tmp
del txt.tmp txt2.tmp
exit /b