none
Variable and Nesting RRS feed

  • Question

  • Hello,

       I am trying:

    set variable=$(wmic csproduct get name)

    echo %variable% 

    variable is not holding model number so that batch file can compare and install drivers accordingly

    because would like to set as below

    Set ListedModel=%variable%

    if %variable% == Dell745 got to driver745

    if %variable% == Dell3040 got to driver3040

    driverxxxx is directory path where to find appropriate driver based on variable


    OR

    if $(wmic csproduct get name) == Dell745 got to driver745 something like this 

    for some reason I have tried to my best ability to research such solution and tried different things and no luck. I appreciate in advance for your time and consideration. 

    Monday, September 16, 2019 1:12 AM

Answers

  • cmd.exe doesn't use $() subexpression syntax (that's PowerShell), but in PowerShell you don't need to run wmic.exe and capture its output because we have Get-WmiObject and/or the CIM cmdlets.

    Unfortunately we can't provide much help with a set of vague and disconnected ideas, but we would definitely recommend learning PowerShell.


    -- Bill Stewart [Bill_Stewart]

    Monday, September 16, 2019 6:25 PM
    Moderator