batch-file - 按供应商搜索软件到 CSV 文件的批处理脚本
问题描述
我想要一个批处理脚本来搜索特定供应商在计算机上的软件并将结果保存到 CSV 文件....我尝试使用以下脚本,但它总是返回 NULL 值,无法弄清楚问题。
@echo off
Set "serial="
For /F "Skip=1 Delims=" %%A In ('WMIC BIOS Get SerialNumber') Do If Not Defined serial Call :Sub %%A
Set serial 2>Nul
:Sub
Set "serial=%*"
Set "LogFile=%serial%.CSV"
If Exist "%LogFile%" Del "%LogFile%"
wmic /Append:"%LogFile%" product where "Name like '%Microsoft%'" get Name, Version /Format:CSV
Start "" "%LogFile%"
exit
解决方案
注意: %
需要用作通配符
在这种情况下,您应该添加另一个百分比字符%
来%Microsfot%
逃避WMIC
批次中的通配符并变得像%%Microsoft%%
@echo off
Title Batch Script to Search for Softwares by Vendor to a CSV file
Set "serial="
For /F "Skip=1 Delims=" %%A In ('WMIC BIOS Get SerialNumber') Do If Not Defined serial Call :Sub %%A
Set serial 2>Nul
:Sub
echo(
echo( Please wait a while ... Searching for installed softwares ....
Set "serial=%*"
Set "LogFile=%serial%.CSV"
If Exist "%LogFile%" Del "%LogFile%"
wmic /Append:"%LogFile%" product where "Name like '%%Microsoft%%'" get Name, Version /Format:CSV
Start "" "%LogFile%"
Exit
推荐阅读
- android - android startActivity 没有在无障碍服务中启动活动
- javascript - 如何在 Angular 9 应用程序中获取电子 autoUpdater 实例?
- android - 为什么`android ServerSocket().accept().getInputStream().read()` 这么慢?
- angular - 如何在http请求角度添加令牌
- npm - 尝试在 siemens iot2040 上安装 node-red 时,npm 读取 ECONNREST 错误
- nginx - 在 Ingress 中添加 allow-http 配置后未禁用 HTTP
- amazon-web-services - 如何将 AWS API Gateway REST API 导出到文件?
- mongodb - Mongoose findOneAndUpdate 用于更新文档中的多个字段
- javascript - 从 - new Date().getTime() 获取时间;
- javascript - 在 React 中使用 localStorage