Rearm Wizard - The Premier Rearm Solution for Windows 7 and Office 2013

Discussion in 'MDL Projects and Applications' started by timesurfer, Mar 27, 2013.

  1. qewlpal

    qewlpal MDL Addicted

    Jun 25, 2010
    575
    2,014
    30
    #181 qewlpal, Apr 19, 2013
    Last edited by a moderator: Apr 20, 2017

    Try this :

    Code:
    for /F "usebackq tokens=2 delims=x" %%A IN (`reg query "%KEY_NAME%" /v "%VALUE_NAME%" 2^>nul ^| find "%VALUE_NAME%"`)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    lol...I'm not getting your idea yet :suicide:

    Why is adding rearm check necessary, cause

    1. It checks if in "noties" if no close
    2. It checks if in "noties" if yes, re-create IR6 30 day task, rearm
    3. It checks if in "noties" if yes and can't rearm, give message

    See I'm thinking between the last 30 days 1................... (We can't tell how :poop: many days are left?)...................30
     
  3. qewlpal

    qewlpal MDL Addicted

    Jun 25, 2010
    575
    2,014
    30
    AFAIK in the last 30 days, it IS in OOBE Grace period and NOT in Notifications..just like the initial 30 days after fresh installation.
    Hope you are clear..
    It goes into Notifications after 180 days to answer your doubt.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,093
    24,397
    340
    Check isn´t nessessary, but shortens the process :D. Not shure about your thoughts regarding days left, as if system is in Notification, there are afaik no days left :hmm:.
    When in Notification and no rearms left, rearming will obviously fail, so you can directly give the message. No need to try rearming and wait to fail to give message afterwards.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    Yes all the trial is in grace

    Let's brake it down so we can see literally what is happening step by step cause having been into the rearm stuff for so long I have instinct it will give message 30 days early, hence there will be two moments that there are 0 rearms

    1. During the last 30 days
    2. At very end of trial, hence at all startup checks will sow 0 rearms but trial is still going

    Start off with 5 rearms 30 days

    30 days go by and comp is off

    Comp turns on and is in "noties" and Check.bat knows this and creates 30 day task and rearms

    Now will zoom to comp having 1 rearm 30 days

    Comp is off again and is in "noties" upon start up, creates 30 day task, rearms now we just have 30 days left

    30 days goes by and comp is off again and in "noties" can't rearm cause 0 rearms and 0 days - give nice message

    I give up :suicide:...lol

    I get what your saying, detection plus noties = give message

    Your using two variables to come to conclusion IR6 reinstall necessary and in that instant rearm check is unnecessary?

    I was just using one variable and you wish to avoid forcing rearm failure with two variables correct?

    Finally I get it :eek:...lol
     
  6. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,455
    989
    60
    #186 Humphrey, Apr 20, 2013
    Last edited by a moderator: Apr 20, 2017
    This is a script to Backup the current *.theme and TranscodedWallpaper.jpg and restores them.

    Code:
    @echo off
    
    setlocal ENABLEEXTENSIONS
    echo. >>%vstore%\IR6Bkup.theme
    echo. >>%vstore%\TranscodedWallpaper.jpg
    
    SETX vstore "%appdata%\..\Local\VirtualStore\IR6" >nul
    
    set KEY_NAME=HKCU\Software\Microsoft\Windows\CurrentVersion\Themes
    set VALUE_NAME=CurrentTheme
    for /F "usebackq tokens=3" %%A IN (`reg query "%KEY_NAME%" /v "%VALUE_NAME%" 2^>nul ^| find "%VALUE_NAME%"`) do (
      SET themefile=%%A
    )
    
    SET wppath=%appdata%\Microsoft\Windows\Themes
    
    mkdir %vstore% >nul
    
    :choice
    cls
    Echo A) Back-Up Background/Theme
    Echo.
    Echo B) Restore Background/Theme
    echo.
    echo C) Exit
    Echo.
    choice /C ABC /N /M "Select one of the options above (A-C):"
    if ERRORLEVEL 3 exit
    if ERRORLEVEL 2 goto Restore
    if ERRORLEVEL 1 goto Backup
    
    :Backup
    
    CLS
    
    xcopy "%wppath%\TranscodedWallpaper.jpg" "%vstore%\TranscodedWallpaper.jpg" /Y
    
    xcopy "%themefile%" "%vstore%\IR6Bkup.theme" /Y
    
    Pause
    
    GOTO CHOICE
    
    :Restore
    
    CLS
    
    xcopy "%vstore%\TranscodedWallpaper.jpg" "%wppath%\TranscodedWallpaper.jpg" /Y
    
    xcopy "%vstore%\IR6Bkup.theme" "C:\Windows\resources\Themes\IR6Bkup.theme" /Y
    
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes"  /t  REG_SZ /v CurrentTheme /d "C:\Windows\resources\Themes\IR6Bkup.theme" /f >NUL
    
    %vstore%\IR6Bkup.theme
    
    Pause
    
    GOTO CHOICE
    
    The lines in red are there cause xcopy ask if destination is file or directory and the user is forced to reply. The lines echo out a dummy file so that the question is skipped. If anyone knows how to get around that?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #187 timesurfer, Apr 20, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Nice work Humphrey :worthy:

    Check.bat is coming along nicely
     
  8. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,093
    24,397
    340
    Exactly, now you got my idea. This will simply shorten the processing time, if both queries (Notification=yes and Rearm Count=0) state, rearm is impossible, only solution in that case is reinstalling IR6 :D.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,455
    989
    60
    Added the red lines to my code.
    Any idea how to get around them and how to shorten the code?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    It was just instinct to keep it simpler but I guess both methods are simple in their own way :poop:

    Will look in little bit :eek:

    But we could just delete any file undesirable after action is done
     
  11. qewlpal

    qewlpal MDL Addicted

    Jun 25, 2010
    575
    2,014
    30
    Try adding /q switch as well to xcopy statement..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #192 timesurfer, Apr 20, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Code:
    xcopy /cheriky
     
  13. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,455
    989
    60
    #193 Humphrey, Apr 20, 2013
    Last edited by a moderator: Apr 20, 2017
    Is that a switch or a combination of the many different switches in xcopy?

    And the dummy files that get created are replaced with the real backup files once xcopy cmd runs.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    Yea that is composite of all those switches

    Look at IORRT backup and you'll find it

    Not sure about dummy file
     
  15. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,455
    989
    60
    #195 Humphrey, Apr 20, 2013
    Last edited by a moderator: Apr 20, 2017
    With your help, color code is done.

    This scirpt (mainly the part in read) makes it so that if the user has a DefaultColor selected in registry, the batch file will use that color instead of the 0F (default color.)

    Code:
    
    @echo off
    color 0F
    pause
    
    setlocal ENABLEEXTENSIONS
    set KEY_NAME=HKCU\Software\Microsoft\Command Processor
    set VALUE_NAME=DefaultColor
    for /F "usebackq tokens=2 delims=x" %%A IN (`reg query "%KEY_NAME%" /v "%VALUE_NAME%" 2^>nul ^| find "%VALUE_NAME%"`) do (
      IF /I %%A EQU 0x0 (goto color) ELSE (Color %%A && goto done)
    )
    
    
    
    
    
    :Color
    title Color Customization
    set bkg=
    set txtclr=
    echo.
    echo  Color Customization
    echo.
    echo  0 = Black
    echo  1 = Blue
    echo  2 = Green
    echo  3 = Aqua
    echo  4 = Red
    echo  5 = Purple
    echo  6 = Yellow
    echo  7 = White
    echo  8 = Gray
    echo  9 = Light Blue
    echo  A = Light Green
    echo  B = Light Aqua
    echo  C = Light Red
    echo  D = Light Purple
    echo  E = Light Yellow
    echo  F = Bright White
    echo  G = Duality
    echo.
    set /p txtclr=    ^   Text Color: 
    if /i "%txtclr%"=="G" goto :mainmenu
    set /p bkg=    ^   Background Color: 
    if /i "%bkg%"=="G" goto :mainmenu
    set bkg=%bkg:~0,1%
    set txtclr=%txtclr:~0,1%
    set bkg=%bkg%
    set txtclr=%txtclr%
    @COLOR %bkg%%txtclr%
    reg add "HKCU\Software\Microsoft\Command Processor"  /t  REG_DWORD /v DefaultColor /d 0x%bkg%%txtclr% /f >NUL
    IF '%ERRORLEVEL%' EQU '0' ( goto color
    ) ELSE (
    exit
    )
    
    
    :done
    echo color selc skipped
    pause
    
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #196 timesurfer, Apr 20, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Nice will add that to D420

    Here is Check.bat code with both rearm code and theme restore

    Code:
    @echo off
    title IR6
    mode con: cols=50 lines=12
    set spp=SoftwareLicensingProduct
    wmic path %spp% get LicenseStatus /format:list 2>nul | findstr /i 5 >nul 2>&1
    if %errorlevel% EQU 0 (
    
    :Rearm
    echo:
    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.
    if %r% == 0 goto :Reinstall
    
    :Reinstall
    setlocal ENABLEEXTENSIONS
    SETX vstore "%appdata%\..\Local\VirtualStore\IR6" >nul
    set KEY_NAME=HKCU\Software\Microsoft\Windows\CurrentVersion\Themes
    set VALUE_NAME=CurrentTheme
    for /F "usebackq tokens=3" %%A IN (`reg query "%KEY_NAME%" /v "%VALUE_NAME%" 2^>nul ^| find "%VALUE_NAME%"`) do (
      SET themefile=%%A
    )
    SET wppath=%appdata%\Microsoft\Windows\Themes
    mkdir %vstore% >nul
    
    :choice
    cls
    Echo A) Back-Up Background/Theme
    Echo.
    Echo B) Restore Background/Theme
    echo.
    echo C) Exit
    Echo.
    choice /C ABC /N /M "Select one of the options above (A-C):"
    if ERRORLEVEL 3 exit
    if ERRORLEVEL 2 goto Restore
    if ERRORLEVEL 1 goto Backup
    
    :Backup
    CLS
    xcopy "%wppath%\TranscodedWallpaper.jpg" "%vstore%\TranscodedWallpaper.jpg" /Y
    xcopy "%themefile%" "%vstore%\IR6Bkup.theme" /Y
    Pause
    GOTO CHOICE
    
    schtasks  /create /tn "IR6" /tr  "'%SystemDrive%\Windows\system32\cmd.exe' /c  cscript.exe /b  %SystemDrive%\Windows\System32\slmgr.vbs /rearm  && net stop  sppsvc && net start sppsvc" /sc daily /mo 30  /ru "" /f >NUL
    "'%SystemDrive%\Windows\system32\cmd.exe' /c  cscript.exe /b  %SystemDrive%\Windows\System32\slmgr.vbs /rearm  && net stop  sppsvc && net start sppsvc" >NUL
    exit
    
    :choice
    cls
    Echo A) Back-Up Background/Theme
    Echo.
    Echo B) Restore Background/Theme
    echo.
    echo C) Exit
    Echo.
    choice /C ABC /N /M "Select one of the options above (A-C):"
    if ERRORLEVEL 3 exit
    if ERRORLEVEL 2 goto Restore
    if ERRORLEVEL 1 goto Backup
    
    :Backup
    CLS
    xcopy "%wppath%\TranscodedWallpaper.jpg" "%vstore%\TranscodedWallpaper.jpg" /Y
    xcopy "%themefile%" "%vstore%\IR6Bkup.theme" /Y
    Pause
    GOTO CHOICE
    
    :Restore
    CLS
    xcopy "%vstore%\TranscodedWallpaper.jpg" "%wppath%\TranscodedWallpaper.jpg" /Y
    xcopy "%vstore%\IR6Bkup.theme" "C:\Windows\resources\Themes\IR6Bkup.theme" /Y
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes"  /t  REG_SZ /v CurrentTheme /d "C:\Windows\resources\Themes\IR6Bkup.theme" /f >NUL
    %vstore%\IR6Bkup.theme
    Pause
    GOTO CHOICE
    schtasks  /create /tn "IR6" /tr  "'%SystemDrive%\Windows\system32\cmd.exe' /c  cscript.exe /b  %SystemDrive%\Windows\System32\slmgr.vbs /rearm  && net stop  sppsvc && net start sppsvc" /sc daily /mo 30  /ru "" /f >NUL
    "'%SystemDrive%\Windows\system32\cmd.exe' /c  cscript.exe /b  %SystemDrive%\Windows\System32\slmgr.vbs /rearm  && net stop  sppsvc && net start sppsvc" >NUL
    goto exit
    )
    endlocal
    
    :Exit
    exit
    Probably wrong but can be readjusted :eek:
     
  17. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,455
    989
    60
    We going for it to ask the user or do it automated in the background?

    I was under the impression that check.bat was only to do what it does in the background and only message the user to notify that IR6 needed reinstalling.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,093
    24,397
    340
    Check. bat should do:
    check license status for Notification string

    if "no" (errorlevel 1) >>> backup theme settings and exit
    if "yes" (errorlevel 0) >>> proceed


    check Rearm Count

    if ≠ "0" >>> rearm and exit
    if = "0" >>> restore theme settings and show message to reinstall IR6




     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,093
    24,397
    340
    Yep, a message box with "OK" and "Cancel", which will start IR6 reinstall on clicking "OK", should offer most possible comfort :good3:.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...