Search code examples
windowsbatch-filecmdwmiwmic

WMI get certification authorities list


I try to write 2 WMIC commands for generate list of all installed applications on mashine and another one all certificates and write it to file.

A problem is that my certificate command does not work properly. the second command returns the same file with installed aplications apart installed certificates. and I really don't understand why, because in my opinion command looks good. This is the following 2 commands:

rem command to check installed aplications
wmic product get /format:csv > %USERPROFILE%/Desktop/vistadraft-applications-%Computername%-%Username%.csv && echo [.] [STARTING] && echo [.] application version list [PROCESSING] && echo [.] [FINISHED]

rem command to check installed certificates
wmic product get /format:csv > %USERPROFILE%/Desktop/vistadraft-certificates-%Computername%-%Username%.csv && echo [.] [STARTING] && echo [.] certification authorities list [PROCESSING] && echo [.] [FINISHED]

Please, maybe whom know where is a problem?


Solution

  • Referencing msdn

    To run the following WMI Command-Line Tools, your account must be in the Administrators group and the tool must be run from an elevated command prompt. The built-in administrator account can also run these tools.

    Therefore you need to run wmic as an administrator.

    a. Simply right click on cmd.exe and select "Run as Administrator" then run your script from there.

    or

    b. save the batch file and right click, selecting Run as Administrator

    Lastly, I suggest you wrap your path in double quotes.

    rem command to check installed aplications
    wmic product get /format:csv > "%USERPROFILE%/Desktop/vistadraft-applications-%Computername%-%Username%.csv" && echo [.] [STARTING] && echo [.] application version list [PROCESSING] && echo [.] [FINISHED]
    
    rem command to check installed certificates
    wmic product get /format:csv > "%USERPROFILE%/Desktop/vistadraft-certificates-%Computername%-%Username%.csv" && echo [.] [STARTING] && echo [.] certification authorities list [PROCESSING] && echo [.] [FINISHED]