Can anyone help me as to how I can store multiple wmic get commands into a single batch file.
The following commands are what I am looking to add in a single batch.
1) wmic os get csname
2) wmic cpu get name
3) wmic os get caption
Now I understand 1 & 3 can be seperated from commas but the Idea is to get wmic os & wmic cpu run in the same batch file and output it to a particular location say c:\hardware.
Thanks in advance.
EDIT: I did figure out how to do that in the meanwhile. Below is the code. However this is saving the output in the form of rows. How can I save the output in the form of columns. That is the computer_name should be in one column and its subsequent row should have the value. Similarly Name should be the next column and its subsequent row should be the model of the laptop etc.
Below is the code:
@echo offif exist C:\dell\%computername%.csv del C:\dell\%computername%.csvset outputfile="C:\dell\%computername%.csv"hostname>>%outputfile%wmic csproduct get name>>%outputfile%wmic bios get serialnumber>>%outputfile%wmic diskdrive get model>>%outputfile%wmic path win32_physicalmedia get SerialNumber>>%outputfile%goto :eof
@echo offif exist C:\dell\%computername%.csv del C:\dell\%computername%.csvset outputfile="C:\dell\%computername%.csv"for /f "delims== tokens=2" %%i in ('wmic csproduct get name /value') do SET CSPRODUCT=%%ifor /f "delims== tokens=2" %%i in ('wmic bios get serialnumber /value') do SET SERIAL=%%ifor /f "delims== tokens=2" %%i in ('wmic diskdrive get model /value') do SET DISK=%%ifor /f "delims== tokens=2" %%i in ('wmic path win32_physicalmedia get SerialNumber /value') do SET PMSERIAL=%%iecho Hostname,Model,Serial,Disk,DiskSerial>>%outputfile%echo %CSPRODUCT%,%SERIAL%,%DISK%,%PMSERIAL%>>%outputfile%
And I can't check here what happens in case the computer has for example more than one harddisk. I'm pretty sure it will fail or deliver incomplete results.
Siddharth S
ASKER
Amazing. Thanks.. !! I will hold onto this for a day. I have a bit of modifications to do post which I will close the question. :)
In the meanwhile if I have any doubts in it, I will resume.
And yes, it is delivering no result when there are 2 Hard disks. But I dont think I need that bit.
Bill Prew
I'm trying something to try and get the disk (multiples) info as well, if you want to wait and see if I have success...
But I would ask you to wait on it as I will be modifying the code quite a bit to get the hardware info. We can try on it once I make changes to my code..
Open in new window
And I can't check here what happens in case the computer has for example more than one harddisk. I'm pretty sure it will fail or deliver incomplete results.