About the author

Related Articles

One Comment

  1. 1
    aschipfl@email.null'

    aschipfl

    To capture the output of the wmic command use for /F:

    set "BOARD="
    for /F "skip=1 delims=" %%I in ('
        wmic BaseBoard get Manufacturer
    ') do (
        for /F "delims=" %%J in ("%%I") do (
            set "BOARD=%%J"
        )
    )
    rem // Compare retrieved string:
    if /I "%BOARD%"=="ASUSTeK COMPUTER INC." (
        echo True
    ) else (
        echo False
    )
    

    The two nested for /F loops are necessary to properly convert the Unicode wmic output.


    However, you could also filter the wmic output directly, like this:

    wmic BaseBoard where "Manufacturer='ASUSTeK COMPUTER INC.'" get Manufacturer 2>&1 > nul | find /V "" > nul && (echo False) || (echo True)
    

    The where clause does the filtering; if no match is found, No Instance(s) Available. is returned on the STD_ERR stream (handle 2). The expression 2>&1 > nul suppresses the STD_OUT stream (handle 1) and redirects STD_ERR to STD_OUT instead, so find is going to receive it; the search expression /V "" finds a match when the stream is not empty. find returns an exit code of 0 if a match is found and 1 otherwise; the operators && and || check the exit code and execute the respective echo command contitionally.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2017 SolutionMmyself.com