We help IT Professionals succeed at work.
Get Started

Multiple wmic commands in a single batch file

Siddharth S
Siddharth S asked
Last Modified: 2016-09-08
Hi Guys,

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 off
if exist C:\dell\%computername%.csv del C:\dell\%computername%.csv
set outputfile="C:\dell\%computername%.csv"


wmic csproduct get name>>%outputfile%

wmic bios get serialnumber>>%outputfile%

wmic diskdrive get model>>%outputfile%

wmic path win32_physicalmedia get SerialNumber>>%outputfile%
goto :eof

Open in new window

Watch Question
Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Distinguished Expert 2020
This problem has been solved!
Unlock 2 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE