读Redirection:
command > filename Redirect command output to a file
command >> filename APPEND into a file
您可以使用>>
,请参阅下一个语法:
wmic product get description,name,version /format:csv >>/softwarelist.csv
阅读wmic/APPEND /?:
APPEND - Specifies the mode for output redirection.
USAGE:
/APPEND:<outputspec>
NOTE: <outputspec> ::= (STDOUT | CLIPBOARD | <filename>)
STDOUT - Output will be redirected to the STDOUT.
CLIPBOARD - Output will be copied on to CLIPBOARD.
<filename> - Output will be appended to the specified file.
NOTE: Enclose the switch value in double quotes, if the value contains special
characters like '-' or '/'.
wmic /APPEND
虽然看起来<filename>
不接受相对路径,看下例子应该正常工作。二者必选其一裸文件名或完整的文件路径:
==> dir /B "\softwarelist.csv"
File Not Found
==> >NUL wmic /APPEND:"\softwarelist.csv" product get description,name,version /format:csv
Invalid file name.
==> >NUL wmic /APPEND:"D:\softwarelist.csv" product get description,name,version /format:csv
==> dir "\softwarelist.csv" | findstr "softwarelist.csv$"
27.08.2016 19:47 48 644 softwarelist.csv
注意dir /B "\softwarelist.csv"
确保在上面的代码片断作品后wmic /APPEND
。
此外,系统驱动器的根目录被保护(因为Vista的次?),看到访问被拒绝消息:
==> pushd c:
==> wmic product get description,name,version /format:csv >/softwarelist.csv
Access is denied.