讀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.