我已經寫了一張在批處理腳本代碼分隔這有點像:創建逗號批處理腳本
(
wmic.exe /node:x.x.x.x computersystem get name
wmic.exe /node:x.x.x.x computersystem get domain
wmic.exe /node:x.x.x.x computersystem get manufacturer
wmic.exe /node:x.x.x.x computersystem get model
wmic.exe /node:x.x.x.x computersystem get username
wmic.exe /node:x.x.x.x computersystem get systemtype
) >> file.txt
的file.txt
內容是:
ABC123
xyz.com
Hewlett-Packard
HP xw4400 Workstation
ABC123\Administrator
x64-based PC
我希望以上信息以CSV格式存儲如下:
ABC123 , xyz.com , Hewlett-Packard , HP xw4400 Workstation , ABC123\Administrator , x64-based PC
這是如何實現的?
完美! 如果我想添加IP地址和MAC地址,該怎麼辦? –
@MandarShinde該數據與'wmic nicconfig'一起提供。但是你需要首先確定你想從哪個網點獲取數據,如果是ip4或ip6或者兩者都有。獲取數據的方式與發佈的代碼相同。檢索一組字段並將它們存儲在變量中,檢索第二組並將其存儲在變量中。然後將變量內容輸出到輸出文件中。 –
如果我必須執行另一個'wmic'命令(比如'wmic cpu')並將其輸出追加到上述命令('wmic computersystem')的輸出旁邊,以便它們出現在同一行中,該怎麼辦? –