0

I'd like to create a batch file using wmic.

WMIC should automatically read my COMPUTERNAME

WMIC single line command is :

wmic /output:c:\COMPUTERNAME_os.list os get /format:list
wmic /output:c:\COMPUTERNAME_sw_installati.list product get /format:list
wmic /output:c:\COMPUTERNAME_av.list /NAMESPACE:\\root\SecurityCenter2 PATH AntiVirusProduct GET /value /format:list
wmic process list full > c:\COMPUTERNAME_process.list
tasklist /svc > c:\COMPUTERNAME_servizio.list
systeminfo > c:\COMPUTERNAME_sysinfo.list

I would be more than grateful if someone can help me.

Thank you

Antonio

1 Answers1

1
  • Read Windows Environment Variables, use %COMPUTERNAME%.
  • Writing files to a disk root C:\ doesn't seem to be a good idea (in the following example, I use %temp% instead).

Your script would be a plain text file (use e.g. Notepad) with .bat or .cmd extension:

@echo OFF
wmic /output:"%temp%\%COMPUTERNAME%_os.list" os get /format:list
wmic /output:"%temp%\%COMPUTERNAME%_sw_installati.list" product get /format:list
wmic /output:"%temp%\%COMPUTERNAME%_av.list" /NAMESPACE:\\root\SecurityCenter2 PATH AntiVirusProduct GET /value /format:list
> "%temp%\%COMPUTERNAME%_process.list" wmic process list full
> "%temp%\%COMPUTERNAME%_servizio.list"tasklist /svc
> "%temp%\%COMPUTERNAME%_sysinfo.list" systeminfo
JosefZ
  • 28,460
  • 5
  • 44
  • 83
  • Thank you very much for the answer. I have made a .bat file with those command lines. Launching the batch file, it starts looping inside the dos window, with no output at all. – Antonio Guarnieri Mar 16 '17 at 07:29
  • The script should work silently. Add `pause` command and some `echo something` to see progress. Try `dir "%temp%\*.list"` and e.g. `type "%temp%\%COMPUTERNAME%_os.list"`. If something goes wrong then [edit your question](http://stackoverflow.com/posts/42800857/edit) and add your current code and error messages as well (follow [mcve]). Now I see a missing space in `> "%temp%\%COMPUTERNAME%_servizio.list" tasklist /svc`,sorry. – JosefZ Mar 16 '17 at 09:47