Dism?

Discussion in 'Scripting' started by timesurfer, Nov 11, 2013.

  1. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,527
    4,112
    270
    Well the topic of discussion is for Rearm Wizard

    MD in prior posts has done an automatic IR7 install because as you know RW install has user going into RE to delete WPA key as to reset rearms to facilitate free trial usage without doing repair install to get rearms back to 5 again

    However we want users to not have to wait long time for automatic install

    So two scenarios:

    1. One we go manually into RE and enter logon info and run a .bat that resets rearms to 5
    2. All that is done completely automatic but takes some time for certain computers (over 10 minutes for my computer)

    My development for RW is basically done but am exploring DISM and WPA delete in case myself or another comes up with better way to reset rearms from inside windows or improve install by automation

    :shisha:
     
  2. Stannieman

    Stannieman MDL Guru

    Sep 4, 2009
    2,232
    1,818
    90
    Why would you need logon info in RE?
    Stripping the RE might help a bit (not original RE then but a new custom that's added to bootoptions).
    Or a small vhd maybe. The KMSnano vm is a lot smaller than RE so it should be doable to strip things down. But that's a whole project on it's own.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,527
    4,112
    270
    IR7 manual install requires logon info to get to RE

    Please look at MD's auto install IR7 script and my RW for better idea what we're doing here please

    RW is small batch and won't be adding any rogue files just working with windows components
     
  4. MasterDisaster

    MasterDisaster MDL Expert

    Aug 29, 2009
    1,256
    674
    60
    Only two things are done to the WIM.
    • reset.bat is added to the root directory
    • Windows\System32\winpeshl.ini is modified to launch reset.bat


    How should I do this without mounting the WIM?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Stannieman

    Stannieman MDL Guru

    Sep 4, 2009
    2,232
    1,818
    90
    #25 Stannieman, Nov 23, 2013
    Last edited: Nov 23, 2013
    You could use delta files but that would need to be done for all languages for all supported windows version for every release -> undoable.
    You can open wim files with 7zip, but it rewrites the complete wim when saving. It still might be faster than mounting, but I don't know how to do it from cmd.
    EDIT: maybe running dism with higher priority helps.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,527
    4,112
    270
    Step 3) Where do I browse for wim?

    And what exactly am I testing here?

    Do I run MD's code after this?

    Thanks
     
  7. Stannieman

    Stannieman MDL Guru

    Sep 4, 2009
    2,232
    1,818
    90
    Isn't extracting and then repacking slower than mounting?

    Mhm, well, I don't know as mounting goes slower than it should be... maybe something to test.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,527
    4,112
    270
    #28 timesurfer, Dec 1, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)
    As to keep RW up to date and/or modernized I will be doing an Automated IR7 install version in red to put on first post

    Questions:

    1. Will this eliminate or complicate the whole drive letter change that happens in RE, hence will user be able to install if they have other drive letters such as D:\, E:\, F:\, etc, thus can we do a error check for "the operation has been successful " and if not automatically enter other drive letter till operation is actually successful

    2. Can we change the C:\ code to system drive for the C:\installkey.bat stuff, etc... to %SystemDrive%\installkey.bat
    3. I might need help writing the reinstall automated code in green

    Here is the latest RW I'll be adapting

    Code:
    @echo off
    cls
    mode con: cols=50 lines=12
    >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
    if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
    ) else ( goto gotAdmin )
    :UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "%~s0", "%params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    exit /B
    :gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"
    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)
    )
    
    :mainmenu
    set userinp=
    title Rearm Wizard
    mode con: cols=50 lines=11
    cls
    echo.
    echo.  
    echo.              ---- Rearm Wizard ----
    echo.    
    echo.            A. IR7 (Windows 7)
    echo.            B. IORRT (Office 2013)
    echo.            C. ISO/URL Links
    echo.            D. ISO Installation Basics
    echo.            E. Color Customization
    echo.            F. Exit
    echo.
    set /p userinp=    ^   Make your selection: 
    set userinp=%userinp:~0,1%
    if /i "%userinp%"=="A" goto IR7
    if /i "%userinp%"=="B" goto IORRT
    if /i "%userinp%"=="C" goto Links
    if /i "%userinp%"=="D" goto ISO
    if /i "%userinp%"=="E" goto Color
    if /i "%userinp%"=="F" goto Exit
    GOTO :mainmenu
    
    :IR7
    REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion | FINDSTR 6.1 >NUL
    IF %ERRORLEVEL% NEQ 0 CLS & echo IR7 supports only windows 7... & ping -n 5 127.0.0.1 >nul & goto mainmenu 
    for /f "tokens=2 delims==" %%A in ('"wmic volume where DriveLetter="%SystemDrive%" get SerialNumber /format:list"') do set sn=%%A
    for /f "tokens=2 delims==" %%A in ('"wmic volume where SystemVolume="true" get DeviceId /format:list"') do set sd=%%A
    
    :Start
    title IR7
    mode con: cols=45 lines=11
    cls
    echo.
    echo.
    echo.             InfiniteRearm7 (IR7)
    echo.                   
    echo.                A. Install
    echo.                B. Uninstall
    echo.                C. Status                
    echo.                D. Instructions
    echo.                E. Rearm Wizard
    echo.                F. Exit
    echo.
    set /p userinp=    ^   Make your selection: 
    set userinp=%userinp:~0,1%
    if /i "%userinp%"=="A" goto InstallIR7
    if /i "%userinp%"=="B" goto UninstallIR7
    if /i "%userinp%"=="C" goto StatusIR7
    if /i "%userinp%"=="D" goto InstructionsIR7
    if /i "%userinp%"=="E" goto MAINMENU
    if /i "%userinp%"=="F" goto Exit
    GOTO start
    
    :InstallIR7
    cls
    schtasks /query | FINDSTR /I "IR7" >NUL 
    IF ERRORLEVEL 1 (
    echo.
    ) ELSE (
    echo IR7 is already installed...
    ping -n 5 127.0.0.1 >nul
    GOTO start
    )
    mode con: cols=42 lines=2
    cls & echo Installing IR7...
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation" /v NotificationDisabled /t REG_DWORD /d 1 /f >NUL
    echo edition = CreateObject("WScript.Shell").RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\EditionID") >key.vbs
    echo Set keys = CreateObject ("Scripting.Dictionary") >>key.vbs
    echo keys.Add "Enterprise",                     "H7X92-3VPBB-Q799D-Y6JJ3-86WC6" >>key.vbs
    echo keys.Add "EnterpriseE",                    "H3V6Q-JKQJG-GKVK3-FDDRF-TCKVR" >>key.vbs
    echo keys.Add "EnterpriseN",                    "BQ4TH-BWRRY-424Y9-7PQX2-B4WBD" >>key.vbs
    echo keys.Add "HomeBasic",                      "YGFVB-QTFXQ-3H233-PTWTJ-YRYRV" >>key.vbs
    echo keys.Add "HomeBasicE",                     "VTKM9-74GQY-K3W94-47DHV-FTXJY" >>key.vbs
    echo keys.Add "HomeBasicN",                     "MD83G-H98CG-DXPYQ-Q8GCR-HM8X2" >>key.vbs
    echo keys.Add "HomePremium",                    "RHPQ2-RMFJH-74XYM-BH4JX-XM76F" >>key.vbs
    echo keys.Add "HomePremiumE",                   "76BRM-9Q4K3-QDJ48-FH4F3-9WT2R" >>key.vbs
    echo keys.Add "HomePremiumN",                   "D3PVQ-V7M4J-9Q9K3-GG4K3-F99JM" >>key.vbs
    echo keys.Add "Professional",                   "HYF8J-CVRMY-CM74G-RPHKF-PW487" >>key.vbs
    echo keys.Add "ProfessionalE",                  "3YHKG-DVQ27-RYRBX-JMPVM-WG38T" >>key.vbs
    echo keys.Add "ProfessionalN",                  "BKFRB-RTCT3-9HW44-FX3X8-M48M6" >>key.vbs
    echo keys.Add "Starter",                        "7Q28W-FT9PC-CMMYT-WHMY2-89M6G" >>key.vbs
    echo keys.Add "StarterE",                       "BRQCV-K7HGQ-CKXP6-2XP7K-F233B" >>key.vbs
    echo keys.Add "StarterN",                       "D4C3G-38HGY-HGQCV-QCWR8-97FFR" >>key.vbs
    echo keys.Add "Ultimate",                       "D4F6K-QK3RD-TMVMJ-BBMRX-3MBMV" >>key.vbs
    echo keys.Add "UltimateE",                      "TWMF7-M387V-XKW4Y-PVQQD-RK7C8" >>key.vbs
    echo keys.Add "UltimateN",                      "HTJK6-DXX8T-TVCR6-KDG67-97J8Q" >>key.vbs
    echo if keys.Exists(edition) then >>key.vbs
    echo WScript.Echo keys.Item(edition) >>key.vbs
    echo End If >>key.vbs
    FOR /F %%A in ('cscript /nologo key.vbs') do SET PIDKEY=%%A
    del key.vbs
    for /f "tokens=2 delims==" %%A in ('"wmic volume where SystemVolume="true" get DeviceId /format:list"') do set sd=%%A
    for /f "tokens=2 delims==" %%A in ('"wmic volume where DriveLetter="%SystemDrive%" get SerialNumber /format:list"') do set sn=%%A
    SET file=%sd%\IR7.bat
    echo @echo off>>%file% 
    echo echo Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")^>^>drive.vbs>>%file% 
    echo echo Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Volume",,48)^>^>drive.vbs>>%file% 
    echo echo For Each objItem in colItems^>^>drive.vbs>>%file% 
    echo echo If Hex(%sn%) = Hex(objItem.SerialNumber) then^>^>drive.vbs>>%file% 
    echo echo Wscript.Echo objItem.DriveLetter^>^>drive.vbs>>%file% 
    echo echo End If ^>^>drive.vbs>>%file% 
    echo echo Next ^>^>drive.vbs>>%file% 
    echo for /f %%%%A IN ('"cscript /nologo drive.vbs"') do set dl=%%%%A>>%file% 
    echo :loop>>%file%
    echo if "%%dl:~-1%%"==" " set "dl=%%dl:~0,-1%%" ^& goto :loop>>%file%
    echo del drive.vbs>>%file% 
    echo reg load HKLM\MY_SYSTEM "%%dl%%\Windows\System32\config\system" ^>NUL >>%file% 
    echo reg delete HKLM\MY_SYSTEM\WPA /f ^>NUL >>%file% 
    echo reg unload HKLM\MY_SYSTEM ^>NUL >>%file%
    echo echo cscript /b slmgr.vbs /ipk %PIDKEY%^>%%dl%%\installkey.bat >>%file%
    echo echo del "C:\installkey.bat" ^>^>%%dl%%\installkey.bat >>%file%
    echo echo CreateObject("WScript.Shell").Run """C:\installkey.bat""", 0, False^>%%dl%%\key.vbs >>%file%
    echo echo @echo off ^>%%dl%%\launch.bat >>%file%
    echo echo wscript.exe "C:\key.vbs" ^>^>%%dl%%\launch.bat >>%file%
    echo echo del "%sd%\IR7.bat" ^>^>%%dl%%\launch.bat >>%file%
    echo echo del "C:\key.vbs" ^>^>%%dl%%\launch.bat >>%file%
    echo echo del "C:\launch.bat" ^>^>%%dl%%\launch.bat >>%file%
    echo reg load HKLM\MY_SOFTWARE "%%dl%%\Windows\System32\config\software" ^>NUL >>%file% 
    echo reg add HKLM\MY_SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v InstallKey /t REG_SZ /d C:\launch.bat /f ^>NUL >>%file%
    echo reg unload HKLM\MY_SOFTWARE >>%file%
    echo wpeutil reboot >>%file%
    schtasks /query | FINDSTR /I "IORRT" >NUL 
    IF ERRORLEVEL 1 (
    GOTO TrialFolder
    ) ELSE (
    GOTO Check
    )
    
    :TrialFolder
    md %SystemDrive%\Trial >nul 2>&1
    GOTO Check
    
    :Check
    md %SystemDrive%\Trial\IR7 >nul 2>&1
    echo CreateObject("Wscript.Shell").Run "%systemdrive%\Trial\IR7\IR7.bat",0,True >>%SystemDrive%\Trial\IR7\IR7.vbs
    echo @echo off >%SystemDrive%\Trial\IR7\IR7.bat
    echo setlocal ENABLEDELAYEDEXPANSION >>%SystemDrive%\Trial\IR7\IR7.bat
    echo SETX IR7backup "%%SystemDrive%%\Trial\IR7" ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat
    echo set KEY_NAME=HKCU\Software\Microsoft\Windows\CurrentVersion\Themes>>%SystemDrive%\Trial\IR7\IR7.bat
    echo set VALUE_NAME=CurrentTheme>>%SystemDrive%\Trial\IR7\IR7.bat
    echo set spp=SoftwareLicensingProduct>>%SystemDrive%\Trial\IR7\IR7.bat
    echo for /F "usebackq tokens=3*" %%%%A IN (`reg query "%%KEY_NAME%%" /v "%%VALUE_NAME%%" 2^^^>nul ^^^| find "%%VALUE_NAME%%"`) do IF ~%%%%B==~ (SET themefile=%%%%A) ELSE (SET themefile=%%%%A %%%%B)>>%SystemDrive%\Trial\IR7\IR7.bat
    echo for %%%%F in ("%%themefile%%") do set theme=%%%%~nF>>%SystemDrive%\Trial\IR7\IR7.bat
    echo set wppath=%%appdata%%\Microsoft\Windows\Themes>>%SystemDrive%\Trial\IR7\IR7.bat
    echo for /f "tokens=2,3,4,5,6,7 delims= " %%%%a in ('wmic os get caption') do set ver=%%%%a %%%%b %%%%c %%%%d %%%%e %%%%f >>%SystemDrive%\Trial\IR7\IR7.bat
    echo :loopV >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if "%%ver:~-1%%"==" " set "ver=%%ver:~0,-1%%" ^& goto :loopV >>%SystemDrive%\Trial\IR7\IR7.bat
    echo wmic path %%spp%% get LicenseStatus /format:list 2^>nul ^| findstr /i 5 ^>nul 2^>^&1 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if %%errorlevel%%==0 goto :Check2 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if %%errorlevel%%==1 goto :Backup >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :Backup>>%SystemDrive%\Trial\IR7\IR7.bat
    echo if "%%ver%%" == "Windows 7 Starter" ( goto :Exit ) >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if "%%ver%%" == "Windows 7 Home Basic" ( goto :BackupHB ) >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if exist "%%systemdrive%%\Trial\IR7\IR7.theme" del /s /q "%%systemdrive%%\Trial\IR7\IR7.theme" ^>nul>>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo F ^| xcopy "%%themefile%%" /s /q "%%systemdrive%%\Trial\IR7" /V /Y ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat
    echo ren "%%systemdrive%%\Trial\IR7\%%theme%%.theme" "IR7.theme">>%SystemDrive%\Trial\IR7\IR7.bat
    echo goto :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :BackupHB >>%SystemDrive%\Trial\IR7\IR7.bat
    echo xcopy "%%wppath%%\TranscodedWallpaper.jpg" /s /q "%%systemdrive%%\Trial\IR7" /Y ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat
    echo goto :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    echo :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    echo ENDLOCAL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :Check2>>%SystemDrive%\Trial\IR7\IR7.bat
    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 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if %%r%% == 0 goto :Messagebox >>%SystemDrive%\Trial\IR7\IR7.bat
    echo cscript.exe /b %%windir%%\system32\slmgr.vbs /rearm >>%SystemDrive%\Trial\IR7\IR7.bat
    echo net stop sppsvc ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo net start sppsvc ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /create /tn "IR7" /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%\Trial\IR7\IR7.bat 
    echo if "%%ver%%" == "Windows 7 Starter" ( goto :RestoreS ) >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if "%%ver%%" == "Windows 7 Home Basic" ( goto :RestoreHB ) >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo F ^| xcopy "%%systemdrive%%\Trial\IR7\IR7.theme" /s /q "%%windir%%\resources\Themes" /V /Y ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat
    echo control desktop >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo Set WshShell = WScript.CreateObject("WScript.Shell") ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.Run "%windir%\\resources\\themes\\IR7.theme" ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo Wscript.Sleep 7000 ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.AppActivate("Desktop Properties") ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.Sendkeys "%%%%FC" ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.Sendkeys "{F4}" ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo call %temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo del %temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes" /t REG_SZ /v CurrentTheme /d "%%windir%%\resources\Themes\IR7.theme" /f ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo goto :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :RestoreS >>%SystemDrive%\Trial\IR7\IR7.bat
    echo reg add "HKCU\Control Panel\Desktop" /f /v "Wallpaper" /d "%%windir%%\web\wallpaper\windows\img0.jpg" /t "REG_SZ" ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo set args=WScript.Arguments ^>msgbox.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo wscript.quit MsgBox(Replace(Replace(args.item(1),"{cr}",vbNewLine,1,-1,1),"{qt}",Chr(34),1,-1,1),args.item(2),args.item(0)) ^>^>msgbox.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo msgbox.vbs "IR7" "LOGOFF required. Log Off now?" 4 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo IF %%ERRORLEVEL%% EQU 6 del /s /q msgbox.vbs ^>nul ^&^& shutdown /l ^&^& call :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    echo IF %%ERRORLEVEL%% EQU 7 del /s /q msgbox.vbs ^>nul ^&^& call :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :RestoreHB >>%SystemDrive%\Trial\IR7\IR7.bat
    echo xcopy "%%systemdrive%%\Trial\IR7\TranscodedWallpaper.jpg" /s /q "%%wppath%%" /Y ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat
    echo reg add "HKCU\Control Panel\Desktop" /f /v "Wallpaper" /d "%%wppath%%\TranscodedWallpaper.jpg" /t "REG_SZ" ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo set args=WScript.Arguments ^>msgbox.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo wscript.quit MsgBox(Replace(Replace(args.item(1),"{cr}",vbNewLine,1,-1,1),"{qt}",Chr(34),1,-1,1),args.item(2),args.item(0)) ^>^>msgbox.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo msgbox.vbs "IR7" "LOGOFF required. Log Off now?" 4 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo IF %%ERRORLEVEL%% EQU 6 del /s /q msgbox.vbs ^>nul ^&^& shutdown /l ^&^& call :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    echo IF %%ERRORLEVEL%% EQU 7 del /s /q msgbox.vbs ^>nul ^&^& call :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :Messagebox>>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo set args=WScript.Arguments ^>msgbox.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo wscript.quit MsgBox(Replace(Replace(args.item(1),"{cr}",vbNewLine,1,-1,1),"{qt}",Chr(34),1,-1,1),args.item(2),args.item(0)) ^>^>msgbox.vbs >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo msgbox.vbs "IR7" "Your 180 day free trial has ended, do you wish to install IR7 again?" 4 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo IF %%ERRORLEVEL%% EQU 6 del /s /q msgbox.vbs ^>nul ^&^& call :ReinstallIR7>>%SystemDrive%\Trial\IR7\IR7.bat
    echo IF %%ERRORLEVEL%% EQU 7 del /s /q msgbox.vbs ^>nul ^&^& call :UninstallIR7>>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :UninstallIR7>>%SystemDrive%\Trial\IR7\IR7.bat
    echo REG  ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation" /v NotificationDisabled /t REG_DWORD /d 0 /f ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /delete /tn "IR7" /f ^>NUL 2>&1 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /delete /tn "Hybrid2" /f ^>NUL 2>&1 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /delete /tn "Hybrid3" /f >NUL 2>&1 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /query ^| FINDSTR /I "IORRT" ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo IF ERRORLEVEL 1 ( >>%SystemDrive%\Trial\IR7\IR7.bat
    echo GOTO TrialFolderDelete >>%SystemDrive%\Trial\IR7\IR7.bat
    echo ) ELSE ( >>%SystemDrive%\Trial\IR7\IR7.bat
    echo GOTO IR7FolderDelete >>%SystemDrive%\Trial\IR7\IR7.bat
    echo ) >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :TrialFolderDelete>>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo rd /s /q %SystemDrive%\Trial ^>NUL ^>^>%SystemDrive%\removeTrial.bat >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo schtasks /delete /tn "removeTrial" /f ^>NUL ^>^>%SystemDrive%\removeTrial.bat >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo del /F /Q %SystemDrive%\removeTrial.bat ^>nul ^>^>%SystemDrive%\removeTrial.bat >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /create /tn "removeTrial" /tr "%SystemDrive%\removeTrial.bat" /sc onlogon /ru "" ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /run /tn "removeTrial" ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo GOTO :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :IR7FolderDelete>>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo rd /s /q %SystemDrive%\Trial\IR7 ^>NUL ^>^>%SystemDrive%\removeIR7.bat >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo schtasks /delete /tn "removeIR7" /f ^>NUL ^>^>%SystemDrive%\removeIR7.bat >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo del /F /Q %SystemDrive%\removeIR7.bat ^>nul ^>^>%SystemDrive%\removeIR7.bat >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /create /tn "removeIR7" /tr "%SystemDrive%\removeIR7.bat" /sc onlogon /ru "" ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /run /tn "removeIR7" ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo GOTO :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :ReinstallIR7>>%SystemDrive%\Trial\IR7\IR7.bat
    echo REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation" /v NotificationDisabled /t REG_DWORD /d 1 /f ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo edition = CreateObject("WScript.Shell").RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\EditionID") ^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo Set keys = CreateObject ("Scripting.Dictionary") ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "Enterprise",                     "H7X92-3VPBB-Q799D-Y6JJ3-86WC6" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "EnterpriseE",                    "H3V6Q-JKQJG-GKVK3-FDDRF-TCKVR" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "EnterpriseN",                    "BQ4TH-BWRRY-424Y9-7PQX2-B4WBD" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "HomeBasic",                      "YGFVB-QTFXQ-3H233-PTWTJ-YRYRV" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "HomeBasicE",                     "VTKM9-74GQY-K3W94-47DHV-FTXJY" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "HomeBasicN",                     "MD83G-H98CG-DXPYQ-Q8GCR-HM8X2" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "HomePremium",                    "RHPQ2-RMFJH-74XYM-BH4JX-XM76F" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "HomePremiumE",                   "76BRM-9Q4K3-QDJ48-FH4F3-9WT2R" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "HomePremiumN",                   "D3PVQ-V7M4J-9Q9K3-GG4K3-F99JM" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "Professional",                   "HYF8J-CVRMY-CM74G-RPHKF-PW487" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "ProfessionalE",                  "3YHKG-DVQ27-RYRBX-JMPVM-WG38T" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "ProfessionalN",                  "BKFRB-RTCT3-9HW44-FX3X8-M48M6" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "Starter",                        "7Q28W-FT9PC-CMMYT-WHMY2-89M6G" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "StarterE",                       "BRQCV-K7HGQ-CKXP6-2XP7K-F233B" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "StarterN",                       "D4C3G-38HGY-HGQCV-QCWR8-97FFR" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "Ultimate",                       "D4F6K-QK3RD-TMVMJ-BBMRX-3MBMV" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "UltimateE",                      "TWMF7-M387V-XKW4Y-PVQQD-RK7C8" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo keys.Add "UltimateN",                      "HTJK6-DXX8T-TVCR6-KDG67-97J8Q" ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo if keys.Exists(edition) then ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WScript.Echo keys.Item(edition) ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo End If ^>^>key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo FOR /F %%%%A in ('cscript /nologo key.vbs') do SET PIDKEY=%%%%A >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo del key.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo for /f "tokens=2 delims==" %%%%A in ('"wmic volume where SystemVolume="true" get DeviceId /format:list"') do set sd=%%%%A>>%SystemDrive%\Trial\IR7\IR7.bat
    echo for /f "tokens=2 delims==" %%%%A in ('"wmic volume where DriveLetter="%%SystemDrive%%" get SerialNumber /format:list"') do set sn=%%%%A >>%SystemDrive%\Trial\IR7\IR7.bat
    echo SET file=%%sd%%\IR7.bat >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo @echo off^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")^^^>^^^>drive.vbs^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_Volume",,48)^^^>^^^>drive.vbs^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo For Each objItem in colItems^^^>^^^>drive.vbs^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo If Hex(%%sn%%) = Hex(objItem.SerialNumber) then^^^>^^^>drive.vbs^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo Wscript.Echo objItem.DriveLetter^^^>^^^>drive.vbs^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo End If ^^^>^^^>drive.vbs^>^>%%file%%>>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo Next ^^^>^^^>drive.vbs^>^>%%file%%>>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo for /f %%%%%%%%A IN ('"cscript /nologo drive.vbs"') do set dl=%%%%%%%%A^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo :loop^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo if "%%%%dl:~-1%%%%"==" " set "dl=%%%%dl:~0,-1%%%%" ^^^& goto :loop^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo del drive.vbs^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo reg load HKLM\MY_SYSTEM "%%%%dl%%%%\Windows\System32\config\system" ^^^>NUL ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo reg delete HKLM\MY_SYSTEM\WPA /f ^^^>NUL ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo reg unload HKLM\MY_SYSTEM ^^^>NUL ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo cscript /b slmgr.vbs /ipk %%PIDKEY%%^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if "%%ver%%" == "Windows 7 Starter" ( goto :WriteS ) >>%SystemDrive%\Trial\IR7\IR7.bat
    echo if "%%ver%%" == "Windows 7 Home Basic" ( goto :WriteHB ) >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo xcopy "%%%%%%%%systemdrive%%%%%%%%\Trial\IR7\IR7.theme" /s /q "%%%%%%%%windir%%%%%%%%\resources\Themes" /Y /V ^^^^^^^>null^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo control desktop >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo Set WshShell = WScript.CreateObject("WScript.Shell") ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.Run "%windir%\\resources\\themes\\IR7.theme" ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo Wscript.Sleep 7000 ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.AppActivate("Desktop Properties") ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.Sendkeys "%%%%FC" ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo WshShell.Sendkeys "{F4}" ^>^>%temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo call %temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    echo del %temp%\IR7.vbs >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :ResumeIR7 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo del "C:\installkey.bat" ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%%>>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo CreateObject("WScript.Shell").Run """C:\installkey.bat""", 0, False^^^>%%%%dl%%%%\key.vbs ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo @echo off ^^^>%%%%dl%%%%\launch.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo wscript.exe "C:\key.vbs" ^^^>^^^>%%%%dl%%%%\launch.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo del "%%sd%%\IR7.bat" ^^^>^^^>%%%%dl%%%%\launch.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo del "C:\key.vbs" ^^^>^^^>%%%%dl%%%%\launch.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo del "C:\launch.bat" ^^^>^^^>%%%%dl%%%%\launch.bat ^>^>%%file%%>>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo reg load HKLM\MY_SOFTWARE "%%%%dl%%%%\Windows\System32\config\software" ^^^>NUL ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo reg add HKLM\MY_SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v InstallKey /t REG_SZ /d C:\launch.bat /f ^^^>NUL ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo reg unload HKLM\MY_SOFTWARE ^>^>%%file%%>> %SystemDrive%\Trial\IR7\IR7.bat
    echo echo wpeutil reboot ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo reagentc /boottore ^>NUL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo schtasks /create /tn "IR7" /tr "'%%SystemDrive%%\Windows\system32\cmd.exe' /c cscript.exe /b C:\Windows\System32\slmgr.vbs /rearm && net stop sppsvc && net start sppsvc" /sc daily /mo 30 /ru "" /f ^>nul >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo shutdown.exe /r /t 0 >>%SystemDrive%\Trial\IR7\IR7.bat
    echo GOTO :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    echo :Exit >>%SystemDrive%\Trial\IR7\IR7.bat
    echo ENDLOCAL >>%SystemDrive%\Trial\IR7\IR7.bat
    echo exit >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :WriteS >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo reg add "HKCU\Control Panel\Desktop" /f /v "Wallpaper" /d "%%%%%%%%windir%%%%%%%%\web\wallpaper\windows\img0.jpg" /t "REG_SZ" ^^^^^^^>nul ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo echo set args=WScript.Arguments ^^^^^^^>msgbox.vbs^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat  
    echo echo echo echo wscript.quit MsgBox(Replace(Replace(args.item(1),"{cr}",vbNewLine,1,-1,1),"{qt}",Chr(34),1,-1,1),args.item(2),args.item(0)) ^^^^^^^>^^^^^^^>msgbox.vbs ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo msgbox.vbs "IR7" "LOGOFF required. Log Off now?" 4 ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo IF %%%%%%%%ERRORLEVEL%%%%%%%% EQU 6 del /s /q msgbox.vbs ^^^^^^^>nul ^^^^^^^& shutdown /l ^^^^^^^& call :Exit ^^^>^^^>%%%%dl%%%%installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo IF %%%%%%%%ERRORLEVEL%%%%%%%% EQU 7 del /s /q msgbox.vbs ^^^^^^^>nul ^^^^^^^& call :Exit ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo goto :ResumeIR7 >>%SystemDrive%\Trial\IR7\IR7.bat
    
    echo :WriteHB >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo xcopy "%%%%%%%%systemdrive%%%%%%%%\Trial\IR7\TranscodedWallpaper.jpg" /s /q "%%wppath%%" /Y ^^^^^^^>nul ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo reg add "HKCU\Control Panel\Desktop" /f /v "Wallpaper" /d "%%wppath%%\TranscodedWallpaper.jpg" /t "REG_SZ" ^^^^^^^>nul ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo echo set args=WScript.Arguments ^^^^^^^>msgbox.vbs ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo echo wscript.quit MsgBox(Replace(Replace(args.item(1),"{cr}",vbNewLine,1,-1,1),"{qt}",Chr(34),1,-1,1),args.item(2),args.item(0)) ^^^^^^^>^^^^^^^>msgbox.vbs ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo msgbox.vbs "IR7" "LOGOFF required. Log Off now?" 4 ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo echo echo IF %%%%%%%%ERRORLEVEL%%%%%%%% EQU 6 del /s /q msgbox.vbs ^^^^^^^>nul ^^^^^^^& shutdown /l ^^^^^^^& call :Exit ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat 
    echo echo echo IF %%%%%%%%ERRORLEVEL%%%%%%%% EQU 7 del /s /q msgbox.vbs ^^^^^^^>nul ^^^^^^^& call :Exit ^^^>^^^>%%%%dl%%%%\installkey.bat ^>^>%%file%% >>%SystemDrive%\Trial\IR7\IR7.bat
    echo goto :ResumeIR7 >>%SystemDrive%\Trial\IR7\IR7.bat
    reagentc /boottore >NUL
    cls & echo Windows is restarting now...
    attrib +h "%SystemDrive%\Trial\IR7"
    attrib +h "%SystemDrive%\Trial"
    schtasks /create /tn "IR7" /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
    schtasks /create /tn "Hybrid2" /tr "%SystemDrive%\Trial\IR7\IR7.vbs" /sc onlogon /rl highest /f >nul
    schtasks /create /tn "Hybrid3" /tr "taskkill /f /im slui.exe" /sc onlogon /ru "" >nul
    shutdown.exe /r /t 0
    ping -n 5 127.0.0.1 >nul
    GOTO :Exit
    
    :UninstallIR7
    CLS
    schtasks /query | FINDSTR /I "IR7" >NUL 
    IF %ERRORLEVEL%==0 (
    echo.
    ) ELSE ( echo IR7 is already uninstalled...
    ping -n 5 127.0.0.1 >nul
    GOTO start
    )
    cls & echo Uninstalling IR7...
    REG  ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation" /v NotificationDisabled /t REG_DWORD /d 0 /f >NUL
    schtasks /delete /tn "IR7" /f >NUL 2>&1
    schtasks /delete /tn "Hybrid2" /f >NUL 2>&1
    schtasks /delete /tn "Hybrid3" /f >NUL 2>&1
    schtasks /query | FINDSTR /I "IORRT" >NUL 
    IF ERRORLEVEL 1 (
    GOTO TrialFolderDelete
    ) ELSE (
    GOTO IR7FolderDelete
    )
    
    :TrialFolderDelete
    rd /S /Q  %SystemDrive%\Trial
    cls & echo IR7 has been successfully uninstalled...
    ping -n 5 127.0.0.1 >nul
    GOTO Start
    
    :IR7FolderDelete
    rd /S /Q  %SystemDrive%\Trial\IR7
    cls & echo IR7 has been successfully uninstalled...
    ping -n 5 127.0.0.1 >nul
    GOTO Start
    
    :StatusIR7
    mode con: cols=64 lines=8
    echo Retrieving status...
    echo.
    echo.
    echo.
    echo.
    echo.
    cscript.exe %windir%\system32\slmgr.vbs /dlv | FINDSTR /I "Status"
    echo.
    cscript.exe %windir%\system32\slmgr.vbs /dlv | FINDSTR /I "Remaining"
    echo.
    schtasks /query /tn "IR7" 2>NUL | FINDSTR "IR7"
    IF ERRORLEVEL 1 echo IR7 is not installed...
    ping -n 5 127.0.0.1 >nul
    GOTO Start
    
    :InstructionsIR7
    title IR7 Instructions
    mode con: cols=110 lines=22
    echo.
    echo  IR7 Instructions
    echo.
    echo  1. Select Install then your computer will automatically restart into Recovery Environment (RE)
    echo.
    echo  2. Enter your keyboard language and login information
    echo.
    echo  3. Click command prompt and type "C:IR7" (without quotes) then press enter
    echo.
    echo  4. Ignore any non-genuine messages while windows is restarting
    echo.
    echo  5. Desktop watermark will disappear momentarily
    echo.
    echo  * If rearms do not reset try typing D:IR7, E:IR7, F:IR7, G:IR7, H:IR7 or I:IR7 in command prompt at step 3
    echo.
    echo  * If IR7 doesn't boot into (RE) restart your computer and press the F8 function key when BIOS screen flashes
    echo.
    echo  * Then choose the option to repair computer and start over at step 2
    echo.
    echo  * Always install IR7 during your computers normal operating times
    echo.
    pause
    goto start
    
    :IORRT
    setlocal enabledelayedexpansion
    title IORRT
    REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion | FINDSTR 6.1 >NUL
    IF ERRORLEVEL 1 cls & echo IORRT supports Office 2013 only under Windows 7 & ping -n 5 127.0.0.1 >nul & goto mainmenu
    set OfficeArchType=
    if '%processor_architecture%'=='x86' Set OfficeArchType=32 && Goto:EndArchIR7
    goto:WOWIR7
    :WOWIR7
    2>nul REG QUERY HKLM\SOFTWARE\Microsoft\Office\15.0\Common | find /i "InstallRoot" 1>nul
    IF ERRORLEVEL 1 Set OfficeArchType=WOW && Goto:EndArchIR7
    Set OfficeArchType=64
    :EndArchIR7
    if %OfficeArchType%==WOW (
    FOR /F "tokens=2* delims= " %%A IN ('"REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot" /v Path 2>NUL"') DO SET InstallRoot=%%B
    if not defined InstallRoot ( cls & echo Office 2013 is not installed... & ping -n 5 127.0.0.1 >nul & goto mainmenu )
    Goto:FoundPath
    )
    FOR /F "tokens=2* delims= " %%A IN ('"REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\15.0\Common\InstallRoot" /v Path 2>NUL"') DO SET InstallRoot=%%B
    if not defined InstallRoot ( cls & echo Office 2013 is not installed... & ping -n 5 127.0.0.1 >nul & goto mainmenu )
    :FoundPath
    1>nul 2>nul net start osppsvc
    cscript "%InstallRoot%"ospp.vbs /dstatus |FINDSTR /i "KMS_Client" >NUL
    if %errorlevel% EQU 1 ( cls & echo No office 2013 KMS detected... & ping -n 5 127.0.0.1 >nul & goto mainmenu )
    
    :IORRT1
    mode con: cols=45 lines=10
    CLS
    echo.
    echo.  
    echo.    InfiniteOfficeRestoreRearmTask (IORRT) 
    echo.    
    echo.               A. Install
    echo.               B. Uninstall
    echo.               C. Status
    echo.               D. Rearm Wizard
    echo.               E. Exit
    echo.
      
    :CHOOSEACTION1
    set /p userinp=    ^   Make your selection: 
    set userinp=%userinp:~0,1%
    if /i "%userinp%"=="A" goto InstallIORRT
    if /i "%userinp%"=="B" goto UninstallIORRT
    if /i "%userinp%"=="C" goto StatusIORRT
    if /i "%userinp%"=="D" goto MAINMENU
    if /i "%userinp%"=="E" goto Exit
    GOTO IORRT1
    
    :InstallIORRT
    CLS
    title IORRT
    mode con: cols=45 lines=11
    schtasks /query | FINDSTR /I "IORRT" >NUL 
    IF %ERRORLEVEL% NEQ 0 (
    echo.
    ) ELSE (
    echo IORRT is already installed...
    ping -n 5 127.0.0.1 >nul
    GOTO IORRT1
    )
    mode con: cols=62 lines=5
    title IORRT
    echo Installing IORRT...
    echo.
    mkdir "%SystemDrive%\Check"
    net stop osppsvc >NUL
    xcopy /cheriky "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" "%SystemDrive%\Check\Backup\Files\Tokens" >NUL
    mkdir "%SystemDrive%\Check\Backup\Registry" >NUL
    reg save "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" %SystemDrive%\Check\Backup\Registry\OfficeSPPInfo.hiv >NUL
    net start osppsvc >NUL
    IF Exist "%ProgramFiles%\Microsoft Office\Office15\OSPPREARM.exe" (
    "%ProgramFiles%\Microsoft Office\Office15\OSPPREARM.exe" >NUL
    ) ELSE ( "%programfiles(x86)%\Microsoft Office\Office15\OSPPREARM.exe" >NUL
    )
    if errorlevel==0 goto Pass
    net stop osppsvc >NUL
    xcopy /cheriky "%SystemDrive%\Check\Backup\Files\Tokens" "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" >NUL
    REG DELETE HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >NUL
    REG ADD HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >NUL
    reg restore "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" %SystemDrive%\Check\Backup\Registry\OfficeSPPInfo.hiv >NUL
    net start osppsvc >NUL
    DEL "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\Backup.hiv" 2> nul
    SET file=%SystemDrive%\Check
    IF EXIST %file% attrib -h %file%
    RD /S /Q  %file%
    cd /d "%InstallRoot%"
    echo.
    cscript OSPP.VBS /dstatus | FINDSTR /i "Status"
    cscript OSPP.VBS /dstatus | FINDSTR /i "Remaining"
    echo.
    echo No Rearms Detected...
    set msg=No rearms detected
    call :speak "No rearms detected"
    goto :END
    :speak
    echo On Error Resume Next: CreateObject("SAPI.SpVoice").Speak %1 >"%~dp0vc.vbs"
    "%~dp0vc.vbs" & del "%~dp0vc.vbs"
    ping -n 5 127.0.0.1 >nul
    GOTO IORRT1
    :Pass
    net stop osppsvc >NUL
    xcopy /cheriky "%SystemDrive%\Check\Backup\Files\Tokens" "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" >NUL
    REG DELETE HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >NUL
    REG ADD HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >NUL
    reg restore "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" %SystemDrive%\Check\Backup\Registry\OfficeSPPInfo.hiv >NUL
    net start osppsvc >NUL
    DEL "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\Backup.hiv" 2> nul
    SET file=%SystemDrive%\Check
    IF EXIST %file% attrib -h %file%
    RD /S /Q  %file%
    schtasks /query | FINDSTR /I "IR7" >NUL 
    IF ERRORLEVEL 1 (
    GOTO TrialFolder2
    ) ELSE (
    GOTO IR7
    )
    
    :TrialFolder2
    md %SystemDrive%\Trial >nul 2>&1
    GOTO IR7
    
    :IR7
    md %SystemDrive%\Trial\IORRT >nul 2>&1
    net stop osppsvc >NUL
    xcopy /cheriky "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" "%SystemDrive%\Trial\IORRT\Backup\Files\Tokens" >NUL
    mkdir "%SystemDrive%\Trial\IORRT\Backup\Registry"
    reg save "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" %SystemDrive%\Trial\IORRT\Backup\Registry\OfficeSPPInfo.hiv >NUL
    net start osppsvc >NUL
    SET file=%SystemDrive%\Trial\IORRT\IORRT.bat
    IF EXIST %file% attrib -h %file% 
    echo @echo off >%file%
    echo net stop osppsvc >>%file%
    echo xcopy /cheriky "%SystemDrive%\Trial\IORRT\Backup\Files\Tokens" "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" >>%file%
    echo REG DELETE HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >>%file%
    echo REG ADD HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >>%file%
    echo reg restore "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" %SystemDrive%\Trial\IORRT\Backup\Registry\OfficeSPPInfo.hiv >>%file%
    echo net start osppsvc >>%file%
    echo IF Exist "%ProgramFiles%\Microsoft Office\Office15\OSPPREARM.exe" ( >>%file%
    echo "%ProgramFiles%\Microsoft Office\Office15\OSPPREARM.exe" >>%file%
    echo ) ELSE ( "%programfiles(x86)%\Microsoft Office\Office15\OSPPREARM.exe" >>%file%
    echo ) >>%file%
    echo schtasks /delete /tn "IORRT" /f >>%file%
    echo schtasks /create /tn "IORRT" /tr "%SystemDrive%\Trial\IORRT\IORRT.bat" /sc daily /mo 1 /ru "" >>%file%
    IF Exist "%ProgramFiles%\Microsoft Office\Office15\OSPPREARM.exe" (
    "%ProgramFiles%\Microsoft Office\Office15\OSPPREARM.exe" >NUL
    ) ELSE ( "%programfiles(x86)%\Microsoft Office\Office15\OSPPREARM.exe" >NUL
    )
    attrib +h "%SystemDrive%\Trial\IORRT"
    attrib +h "%SystemDrive%\Trial"
    schtasks /create /tn "Hybrid" /tr "%SystemDrive%\Trial\IORRT\IORRT.bat" /sc onlogon /ru "" >NUL
    schtasks /create /tn "IORRT" /tr "%SystemDrive%\Trial\IORRT\IORRT.bat" /sc daily /mo 1 /ru "" >NUL
    echo.
    title IORRT
    cd /d "%InstallRoot%"
    echo.
    echo.
    cscript OSPP.VBS /dstatus | FINDSTR /i "Status"
    cscript OSPP.VBS /dstatus | FINDSTR /i "Remaining"
    echo.
    echo Installation Successful...
    set msg=Installation Successful
    call :speak "Installation Successful"
    goto :END
    :speak
    echo On Error Resume Next: CreateObject("SAPI.SpVoice").Speak %1 >"%~dp0vc.vbs"
    "%~dp0vc.vbs" & del "%~dp0vc.vbs"
    ping -n 5 127.0.0.1 >nul
    GOTO IORRT1
    
    :UninstallIORRT
    schtasks /query | FINDSTR /I "IORRT" >NUL
    IF '%ERRORLEVEL%' EQU '0' (
    echo.
    ) ELSE (
    mode con: cols=45 lines=10
    title IORRT
    echo IORRT is already uninstalled...
    ping -n 5 127.0.0.1 >nul
    GOTO IORRT1
    )
    mode con: cols=62 lines=5
    title IORRT
    echo Uninstalling IORRT...
    echo.
    net stop osppsvc >NUL
    xcopy /cheriky "%SystemDrive%\Trial\IORRT\Backup\Files\Tokens" "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" >NUL
    REG DELETE HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >NUL
    REG ADD HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform /f >NUL
    reg restore "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" %SystemDrive%\Trial\IORRT\Backup\Registry\OfficeSPPInfo.hiv >NUL
    net start osppsvc >NUL
    DEL "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\Backup.hiv" 2> nul
    schtasks /query | FINDSTR /I "IR7" >NUL 
    IF ERRORLEVEL 1 (
    GOTO TrialFolderDelete2
    ) ELSE (
    GOTO IORRTFolderDelete
    )
    
    :TrialFolderDelete2
    rd /S /Q  %SystemDrive%\Trial
    goto Pass2
    
    :IORRTFolderDelete
    rd /S /Q  %SystemDrive%\Trial\IORRT
    goto Pass2
    
    :Pass2
    schtasks /delete /tn "Hybrid" /f >NUL
    schtasks /delete /tn "IORRT" /f >NUL
    cd /d "%InstallRoot%"
    echo.
    echo.
    cscript OSPP.VBS /dstatus | FINDSTR /i "Status" 
    cscript OSPP.VBS /dstatus | FINDSTR /i "Remaining"
    echo.
    echo Successfully Uninstalled...
    set msg=Successfully Uninstalled
    call :speak "Successfully Uninstalled"
    goto :END
    :speak
    echo On Error Resume Next: CreateObject("SAPI.SpVoice").Speak %1 >"%~dp0vc.vbs"
    "%~dp0vc.vbs" & del "%~dp0vc.vbs"
    ping -n 5 127.0.0.1 >nul
    GOTO IORRT1
    
    :StatusIORRT
    mode con: cols=64 lines=6
    title IORRT
    cd /d "%InstallRoot%"
    cscript OSPP.VBS /dstatus | FINDSTR /i "Status"
    cscript OSPP.VBS /dstatus | FINDSTR /i "Remaining"
    echo.
    schtasks /query | FINDSTR /I "IORRT"
    IF ERRORLEVEL 1 echo IORRT is not installed...
    ping -n 5 127.0.0.1 >nul
    GOTO IORRT1
    endlocal
    
    :Links
    CLS
    title ISO/URL Links
    mode con: cols=26 lines=14
    echo.
    echo  ISO/URL Links
    echo.
    echo. A. Rearm Wizard Thread
    echo. B. Windows 7 (x86) ISO
    echo. C. Windows 7 (x64) ISO
    echo. D. ZOTAC WinUSB Maker
    echo. E. Virtual CloneDrive
    echo. F. BitTorrent Client
    echo. G. Office 2013 (x86) ISO
    echo. H. Office 2013 (x64) ISO
    echo. I. Rearm Wizard
    echo.
    set /p deli=    ^   Make your selection: 
    set deli=%deli:~0,1%
    if /i "%deli%"=="A" start http://forums.mydigitallife.net/threads/43861 >nul 2>&1
    if /i "%deli%"=="B" start magnet:?xt=urn:btih:7ad366ff54c1ed20001357bfa344bf75764424b4&dn >nul 2>&1
    if /i "%deli%"=="C" start magnet:?xt=urn:btih:bcaab2bff2b1e337864121887c2404d45726aabc&dn >nul 2>&1
    if /i "%deli%"=="D" start http://forums.mydigitallife.net/threads/47012 >nul 2>&1
    if /i "%deli%"=="E" start http://static.slysoft.com/SetupVirtualCloneDrive.exe >nul 2>&1
    if /i "%deli%"=="F" start http://www.bittorrent.com >nul 2>&1
    if /i "%deli%"=="G" start magnet:?xt=urn:btih:91641B6FC20521D6A5B86B1000140F03E556C175 >nul 2>&1
    if /i "%deli%"=="H" start magnet:?xt=urn:btih:FB03E471B7F46AE03C4C14F42BEFE8063A7283CB >nul 2>&1
    if /i "%deli%"=="I" goto mainmenu
    goto Links
    
    :ISO
    title ISO Installation Basics
    mode con: cols=112 lines=18
    echo.
    echo  ISO Installation Basics
    echo.
    echo  1. Install BitTorrent then download the windows 7 or Office 2013 ISO you wish to burn or mount
    echo  2. Use the ZOTAC WinUSB Maker to burn your Windows 7 ISO to a USB flash drive or SD card
    echo  3. Insert your USB flash drive or SD card into your computer then open the ZOTAC WinUSB Maker
    echo  4. Click on computer in windows and drag your USB flash drive or SD card to the flash drive icon
    echo  5. Then drag your Windows 7 ISO to the Windows icon
    echo  6. Click the "make USB bootable" button
    echo  7. Wait for Windows 7 to be burned to your USB flash drive or SD card
    echo  8. Install windows 7 with updates and internet on
    echo  9. Then you can upgrade or clean install from boot or inside Windows
    echo  10. You can upgrade from Vista, but if you have XP a clean install will be necessary
    echo  11. When installing Windows 7 just bypass entering any key then uncheck the activate online box and click next
    echo  12. Use Virtual CloneDrive to mount the Office 2013 ISO then install from the virtual drive on your computer
    echo  13. After successful office 2013 installation right click the office 2013 virtual drive and click unmount
    echo.
    pause
    goto mainmenu
    
    :Color
    title Color Customization
    set bkg=
    set txtclr=
    mode con: cols=21 lines=22
    CLS
    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 = Rearm Wizard
    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%
    mode con: cols=48 lines=11
    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 (
    goto mainmenu
    )
    
    :Exit
    ENDLOCAL
    exit
    Thanks MD :worthy:

    :shisha:
     
  9. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,527
    4,112
    270
    #29 timesurfer, Dec 2, 2013
    Last edited: Dec 2, 2013
    (OP)
    Tested autoIR7install on 6GB semi fast machine and duration was approximately 8 minutes to get back into windows

    So really we're only asking most users to wait an additional 4-5 minutes for install which is no big deal really but I think I'll offer both auto and manual install versions!?

    I will start to write the autoIR7install into RW's install/reinstall in a couple days

    Thanks :worthy: MD