[Batch] How to retrieve the rearm count in a batch file

Discussion in 'Scripting' started by anemeros, Dec 28, 2010.

  1. anemeros

    anemeros MDL Developer

    Aug 12, 2009
    81
    280
    0
    #1 anemeros, Dec 28, 2010
    Last edited by a moderator: Apr 20, 2017
    Here is a cool way to use the WMI Commandline Utility (WMIC.exe) to retrieve the remaining windows rearm count from the WMI database using a simple batch file.

    Copy and paste the following script into notepad and save it with a ".bat" or ".cmd" filename extension. For example, you can save it as "RearmCount.bat".

    Code:
    @echo off
    setlocal enableextensions
    for /f "usebackq tokens=2 delims==" %%n in (`"%SystemRoot%\System32\wbem\WMIC.exe" /namespace:\\root\cimv2 path SoftwareLicensingService get RemainingWindowsReArmCount /format:list`) do set r=%%n
    if %r% == 1 (set s=) else (set s=s)
    echo.You have %r% rearm%s% remaining.
    pause
    Cheers!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. DARKOR04

    DARKOR04 MDL Tester/Developer

    Jul 5, 2010
    495
    887
    10
    #2 DARKOR04, Jan 30, 2011
    Last edited: Jan 31, 2011
    Deleted... Threads Menu.
     
  3. DARKOR04

    DARKOR04 MDL Tester/Developer

    Jul 5, 2010
    495
    887
    10
    Sorry, Posted Here because same topic... (WMIC).

    Deleted and created Thread: [DONE]