How to write a simple batch file

gloyola1
gloyola1 used Ask the Experts™
on
I need a batch file to run the following from the command prompt:  wmic computersystem get model,name,manufacturer,systemtype

This batch file is for Windows 7 to get details for inventory that I am gathering.  Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
What are you going to do with the output, do you want it in any particular format or in a file?  CSV, plain text?


»bp
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
You can run that command right from a BAT file as it stands, for example:

@echo off
setlocal

wmic computersystem get model,name,manufacturer,systemtype

Open in new window


»bp

Author

Commented:
Hello, I want the end users that run this to send me back the information thru email.  So, as far as output goes something that will make it easy for them to send back to me in an email.  Thanks
Test your restores, not your backups...
Top Expert 2016
Commented:
So would they cut and paste the output into an email, is that your thought?

You might try adding /format:list to the end of the command.  Or adding that and then saving as a file that they could then attach to an email to you.  Below vreates a file on their Desktop called info.txt that they could send you.

@echo off
setlocal

wmic computersystem get model,name,manufacturer,systemtype /format:list>"%USERPROFILE%\Desktop\info.txt"

Open in new window


»bp




»bp

Author

Commented:
Yes, cut and paste.  Thanks
Jeremy WeisingerSenior Network Consultant / Engineer
Commented:
Something simple that would show it in a text file work?
Expanding on Bill's script:
@echo off
setlocal

wmic computersystem get model,name,manufacturer,systemtype > c:\temp\info.txt
notepad c:\temp\info.txt

Open in new window

Author

Commented:
Thanks for the help!
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Welcome, glad that helped.


»bp
Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
Ditto. :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial