Batch file 我想将下面命令的输出存储在批处理文件中的变量中

Batch file 我想将下面命令的输出存储在批处理文件中的变量中,batch-file,Batch File,我想将下面命令的输出存储在批处理文件中的变量中 wmic产品,其中name=“%INPUT%”调用卸载 在输出是否匹配无可用实例之后。然后我想显示您的输入错误,请检查您的输入 如果条件失败,我想显示您选择的产品已成功卸载这是您要查找的吗 for /f "delims=" %%i in ('wmic product where name="%INPUT%" call uninstall') do set output=%%i if "%output%"=="No Instance(s) Avail

我想将下面命令的输出存储在批处理文件中的变量中

wmic产品,其中name=“%INPUT%”调用卸载

在输出是否匹配无可用实例之后。然后我想显示您的输入错误,请检查您的输入


如果条件失败,我想显示您选择的产品已成功卸载

这是您要查找的吗

for /f "delims=" %%i in ('wmic product where name="%INPUT%" call uninstall') do set output=%%i
if "%output%"=="No Instance(s) Available." (
 echo Your input is incorrect
 goto :skip
)
echo The product you selected was successfully uninstalled
:skip
pause

我没有测试过,因为我不在电脑旁。

应该会有帮助。@SomethingDark如果卸载时出现任何错误,我还需要一个。我怎么知道呢?请注意:
wmic
输出是本地语言的。(遗憾的是,
%errorlevel%
始终为零)