[Batch] The Official Batch File Repository - Learn & ask questions about batch files

Discussion in 'Scripting' started by timesurfer, Oct 11, 2010.

  1. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    #141 thethingy, Mar 1, 2011
    Last edited: Mar 1, 2011
    one more way to check admin;

    [​IMG]

    this would need to be put on also with the else on both going the the desired menu;

    [​IMG]
     
  2. chnix

    chnix MDL Member

    May 16, 2010
    147
    71
    10
    #142 chnix, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    @timesurfer

    I'm beginning to study batch script and yours is a great example. I took the liberty to make some changes to your script based on a MasterDisaster's script. It's finds another way to get office installed path and if can not find reports that office is not installed. I have not tested yet but i think it works. Changes in red. What do you think about?

    Code:
    @echo off
    @color 0A
    md %windir%\TrilogyAdminTest 2>NUL
    if %errorlevel%==0 ( 
    rd %windir%\TrilogyAdminTest 
    goto mainmenu
    ) else (
    echo Right click Trilogy and run as administrator
    echo.
    pause
    goto end
    )
    :mainmenu
    title Trilogy 1.3
    mode con: cols=45 lines=9
    CLS
    echo.
    echo.  
    echo.             --- Trilogy 1.3 ---
    echo.    
    echo.                 A. IR5 3.2
    echo.                 B. IORRT 3.5
    echo.                 C. ACS5T 4.2
    echo.                 D. Exit
    echo.
      
    :CHOOSEACTION
    set /p userinp=    ^   Make your selection: 
    set userinp=%userinp:~0,1%
    if /i "%userinp%"=="A" goto IR5
    if /i "%userinp%"=="B" goto IORRT
    if /i "%userinp%"=="C" goto ACS5T
    if /i "%userinp%"=="D" goto Exit
    echo.Try Again...
    GOTO CHOOSEACTION
    
    :IORRT
    @color 0A
    title IORRT 3.5
    
    REM Get Office Installed Path
    for /f "tokens=2,*" %%A in ('"reg query "HKLM\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot" /v Path 2>NUL"') do set InstallRoot=%%B
    if not defined InstallRoot ( 
    for /f "tokens=2,*" %%A in ('"reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot" /v Path 2>NUL"') do set InstallRoot=%%B
    if not defined InstallRoot ( echo Office 2010 not installed! & echo. & pause & goto mainmenu )
    )
    
    :FoundPath
    
    REM Start OSPPSVC (To make sure it is started to prevent strange cases where it doesn't start automatically from failing (XP))
    1>nul 2>nul net start osppsvc
    
    :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. Trilogy
    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 End
    echo.Try Again...
    GOTO CHOOSEACTION1
    
    :InstallIORRT
    CLS
    title IORRT 3.5
    mode con: cols=45 lines=9
    schtasks /query | FINDSTR /I "IORRT" >NUL 
    IF ERRORLEVEL 1 (
    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 3.5
    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 "%CommonProgramFiles%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" (
    "%CommonProgramFiles%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" >NUL
    ) ELSE ( "%commonprogramfiles(x86)%\microsoft shared\OfficeSoftwareProtectionPlatform\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 MAINMENU
    :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%
    mkdir "%SystemDrive%\IORRT"
    net stop osppsvc >NUL
    xcopy /cheriky "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform" "%SystemDrive%\IORRT\Backup\Files\Tokens" >NUL
    mkdir "%SystemDrive%\IORRT\Backup\Registry"
    reg save "HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" %SystemDrive%\IORRT\Backup\Registry\OfficeSPPInfo.hiv >NUL
    net start osppsvc >NUL
    SET file=%SystemDrive%\IORRT\IORRT.bat
    IF EXIST %file% attrib -h %file% 
    echo @echo off >%file%
    echo net stop osppsvc >>%file%
    echo xcopy /cheriky "%SystemDrive%\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%\IORRT\Backup\Registry\OfficeSPPInfo.hiv >>%file%
    echo net start osppsvc >>%file%
    echo IF Exist "%COMMONPROGRAMFILES%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" ( >>%file%
    echo "%COMMONPROGRAMFILES%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" >>%file%
    echo ) ELSE ( "%COMMONPROGRAMFILES(X86)%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" >>%file%
    echo ) >>%file%
    echo schtasks /delete /tn "IORRT" /f >>%file%
    echo schtasks /create /tn "IORRT" /tr "%SystemDrive%\IORRT\IORRT.bat" /sc daily /mo 1 /ru "" >>%file%
    IF Exist "%CommonProgramFiles%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" (
    "%CommonProgramFiles%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" >NUL
    ) ELSE ( "%commonprogramfiles(x86)%\microsoft shared\OfficeSoftwareProtectionPlatform\OSPPREARM.exe" >NUL
    )
    attrib +h "%SystemDrive%\IORRT"
    schtasks /create /tn "Hybrid" /tr "%SystemDrive%\IORRT\IORRT.bat" /sc onstart /ru "" >NUL
    schtasks /create /tn "IORRT" /tr "%SystemDrive%\IORRT\IORRT.bat" /sc daily /mo 1 /ru "" >NUL
    echo.
    title IORRT 3.5
    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=9
    title IORRT 3.5
    echo IORRT is already uninstalled...
    ping -n 5 127.0.0.1 >nul
    GOTO IORRT1
    )
    mode con: cols=62 lines=5
    title IORRT 3.5
    echo Uninstalling IORRT...
    echo.
    net stop osppsvc >NUL
    xcopy /cheriky "%SystemDrive%\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%\IORRT\Backup\Registry\OfficeSPPInfo.hiv >NUL
    net start osppsvc >NUL
    DEL "%ALLUSERSPROFILE%\Microsoft\OfficeSoftwareProtectionPlatform\Backup.hiv" 2> nul
    SET file=%SystemDrive%\IORRT
    IF EXIST %file% attrib -h %file%
    RD /S /Q  %file%
    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 3.5
    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
    )
    
    :IR5
    REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion | FINDSTR 6.1 >NUL
    IF ERRORLEVEL 1 echo Supports Windows 7 and Server 2008 R2 only & goto end
    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
    color 0A
    title IR5 3.2
    mode con: cols=45 lines=12
    cls
    echo.
    echo.
    echo.             InfiniteRearm5 (IR5)
    echo.                   
    echo.                A. Install
    echo.                B. Uninstall
    echo.                C. Rearm
    echo.                D. Status                
    echo.                E. Instructions
    echo.                F. Trilogy
    echo.                G. Exit
    echo.
    
    :CHOOSEACTION2
    set /p userinp=    ^   Make your selection: 
    set userinp=%userinp:~0,1%
    if /i "%userinp%"=="A" goto InstallIR5
    if /i "%userinp%"=="B" goto UninstallIR5
    if /i "%userinp%"=="C" goto RearmIR5
    if /i "%userinp%"=="D" goto StatusIR5
    if /i "%userinp%"=="E" goto InstructionsIR5
    if /i "%userinp%"=="F" goto MAINMENU
    if /i "%userinp%"=="G" goto End
    echo.Try Again...
    GOTO CHOOSEACTION2
    
    :InstallIR5
    CLS
    schtasks /query | FINDSTR /I "IR5" >NUL 
    IF ERRORLEVEL 1 (
    echo.
    ) ELSE (
    echo IR5 is already installed...
    ping -n 5 127.0.0.1 >nul
    GOTO start
    )
    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 "ServerDatacenter",               "7X29B-RDCR7-J6R29-K27FF-H9CR9" >>key.vbs
    echo keys.Add "ServerDatacenterCore",           "7X29B-RDCR7-J6R29-K27FF-H9CR9" >>key.vbs
    echo keys.Add "ServerEmbeddedSolution",         "M2KD2-F2333-Q3TJ8-BQMHX-9PWX6" >>key.vbs
    echo keys.Add "ServerEmbeddedSolutionCore",     "M2KD2-F2333-Q3TJ8-BQMHX-9PWX6" >>key.vbs
    echo keys.Add "ServerEnterprise",               "7P8GH-FV2FF-8FDCR-YK49D-D7P97" >>key.vbs
    echo keys.Add "ServerEnterpriseCore",           "7P8GH-FV2FF-8FDCR-YK49D-D7P97" >>key.vbs
    echo keys.Add "ServerEnterpriseIA64",           "7YKJ4-CX8QP-Q23QY-7BYQM-H2893" >>key.vbs
    echo keys.Add "ServerEssentialAdditional",      "7PDBG-28HK4-276G6-XVJF4-KH9Y4" >>key.vbs
    echo keys.Add "ServerEssentialAdditionalSvc",   "RCDPD-97Q7B-MRDC3-GTRYF-MCD6G" >>key.vbs
    echo keys.Add "ServerEssentialManagement",      "4F37J-4YTKY-6DFDJ-FDRFY-2HT34" >>key.vbs
    echo keys.Add "ServerEssentialManagementSvc",   "4HFV2-KB9P6-TQVJF-87D8X-2YYBF" >>key.vbs
    echo keys.Add "ServerForSBSolutions",           "PHYFD-HQ4XW-78PR4-2CXKF-V67KJ" >>key.vbs
    echo keys.Add "ServerForSBSolutionsEM",         "JR4Y2-WC84X-PBRDJ-QTBTB-TQGGH" >>key.vbs
    echo keys.Add "ServerHomePremium",              "4BWDV-9MKGX-V9QJ4-YWFWR-P6974" >>key.vbs
    echo keys.Add "ServerHomeStandard",             "MCQYD-2TJYQ-JP7KR-7GYYF-YGPXQ" >>key.vbs
    echo keys.Add "ServerHPC",                      "Q7PRR-M2WBM-RJJ99-FG393-MGY3B" >>key.vbs
    echo keys.Add "ServerHyperCore",                "Q8R8C-T2W6H-7MGPB-4CQ9R-KR36H" >>key.vbs
    echo keys.Add "ServerMediumBusinessManagement", "FD499-FD79G-V9D2W-F9WQ6-MD2VC" >>key.vbs
    echo keys.Add "ServerMediumBusinessMessaging",  "YVYC7-KVQ8G-XF6K4-9MG8M-QXFC2" >>key.vbs
    echo keys.Add "ServerMediumBusinessSecurity",   "YQ3V7-79DM4-42PVW-BYRH8-69VXK" >>key.vbs
    echo keys.Add "ServerSBSPremium",               "BXQQP-Q6Q6D-TR7TR-3YXQW-VFHKM" >>key.vbs
    echo keys.Add "ServerSBSPremiumCore",           "BXQQP-Q6Q6D-TR7TR-3YXQW-VFHKM" >>key.vbs
    echo keys.Add "ServerSBSStandard",              "YMFM8-J2RV2-66G78-XPQ7C-4RY3B" >>key.vbs
    echo keys.Add "ServerSolution",                 "Y7GVM-YFQQW-HV8HW-GRW6D-YJ84M" >>key.vbs
    echo keys.Add "ServerSolutionEM",               "WF9T8-VT7D2-GD629-WTKGH-3WBJT" >>key.vbs
    echo keys.Add "ServerSolutionsPremium",         "4TMY4-8JG4B-VKY8X-6TVDH-J7XFV" >>key.vbs
    echo keys.Add "ServerSolutionsPremiumCore",     "4TMY4-8JG4B-VKY8X-6TVDH-J7XFV" >>key.vbs
    echo keys.Add "ServerStandard",                 "HMG6P-C7VGP-47GJ9-TWBD4-2YYCD" >>key.vbs
    echo keys.Add "ServerStandardCore",             "HMG6P-C7VGP-47GJ9-TWBD4-2YYCD" >>key.vbs
    echo keys.Add "ServerWeb",                      "YGTGP-9XH8D-8BVGY-BVK4V-3CPRF" >>key.vbs
    echo keys.Add "ServerWebCore",                  "YGTGP-9XH8D-8BVGY-BVK4V-3CPRF" >>key.vbs
    echo keys.Add "ServerWinFoundation",            "36RXV-4Y4PJ-B7DWH-XY4VW-KQXDQ" >>key.vbs
    echo keys.Add "ServerWinSB",                    "JG43G-CMPHG-VPBC6-9TDQR-RRFJ4" >>key.vbs
    echo keys.Add "ServerWinSBV",                   "WQG3Q-VWT72-VX39Q-VRTRD-2RF7K" >>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
    SET file=%sd%\IR5.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 set dl=%%dl:~0,-1%%>>%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 slmgr.vbs /dlv ^>^>%%dl%%\installkey.bat >>%file%
    echo echo del "%SystemDrive%\installkey.bat" ^>^>%%dl%%\installkey.bat >>%file%
    echo echo CreateObject("WScript.Shell").Run """%SystemDrive%\installkey.bat""", 0, False ^>%%dl%%\key.vbs >>%file%
    echo echo @echo off ^>%%dl%%\launch.bat >>%file%
    echo echo wscript.exe "%SystemDrive%\key.vbs" ^>^>%%dl%%\launch.bat >>%file%
    echo echo del "%sd%\IR5.bat" ^>^>%%dl%%\launch.bat >>%file%
    echo echo del "%SystemDrive%\key.vbs" ^>^>%%dl%%\launch.bat >>%file%
    echo echo del "%SystemDrive%\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 %SystemDrive%\launch.bat ^>NUL >>%file%
    echo reg unload HKLM\MY_SOFTWARE >>%file%
    echo wpeutil reboot >>%file%
    reagentc /boottore >NUL
    IF ERRORLEVEL 1 ( cls & echo Run Trilogy as Administrator...
    echo.
    pause
    goto start
    ) ELSE (
    echo Windows is restarting now...
    ping -n 5 127.0.0.1 >nul
    schtasks /create /tn "IR5" /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
    shutdown /r /t 0
    goto end
    )
    
    :UninstallIR5
    cls
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation" /v NotificationDisabled /t REG_DWORD /d 0 /f >NUL
    schtasks /delete /tn "IR5" /f >NUL 2>&1
    IF %ERRORLEVEL%==0 ( echo IR5 has been successfully uninstalled...
    ) ELSE (
    echo IR5 is already uninstalled...
    )
    ping -n 5 127.0.0.1 >nul
    GOTO Start
    
    :RearmIR5
    CLS
    cscript.exe /b %windir%\system32\slmgr.vbs /rearm
    IF %ERRORLEVEL% NEQ 0 ( echo No rearms detected...
    ping -n 5 127.0.0.1 >nul
    GOTO Start
    ) ELSE (
    net stop sppsvc >NUL
    net start sppsvc >NUL
    echo Rearm completed successfully...
    ping -n 5 127.0.0.1 >nul
    )
    schtasks /query | FINDSTR /i "IR5" >nul
    if %errorlevel%==0 (
    schtasks /create /tn "IR5" /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
    )
    GOTO Start
    
    :StatusIR5
    mode con: cols=51 lines=10
    CLS
    cscript.exe %windir%\system32\slmgr.vbs /dlv | FINDSTR /I "Name"
    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 "IR5" 2>NUL | FINDSTR "IR5"
    IF ERRORLEVEL 1 echo IR5 is not installed...
    ping -n 5 127.0.0.1 >nul
    GOTO Start
    
    :InstructionsIR5
    mode con: cols=100 lines=12
    echo 1. Click Install then your computer will automatically restart and in a moment you will be asked to enter your keyboard language and login information
    echo.
    echo 2. Select command prompt and type "C:IR5" (without quotes) then press enter
    echo.
    echo 3. Ignore any non-genuine messages as windows restarts
    echo.
    echo * Click rearm if license status says "notification"
    echo.
    echo * Reinstall IR5 when you have 0 rearms and 1 days left
    echo.
    pause
    goto start
    
    :ACS5T
    @color 0A
    title ACS5T 4.2
    mode con: cols=45 lines=11
    CLS
    echo.
    echo.  
    echo.       AdobeCreativeSuite5Tool (ACS5T)
    echo.    
    echo.                A. Install
    echo.                B. Uninstall
    echo.                C. Keys
    echo.                D. Instructions
    echo.                E. Trilogy
    echo.                F. Exit
    echo.
      
    :CHOOSEACTION3
    set /p userinp=    ^   Make your selection: 
    set userinp=%userinp:~0,1%
    if /i "%userinp%"=="A" goto InstallACS5T
    if /i "%userinp%"=="B" goto UninstallACS5T
    if /i "%userinp%"=="C" goto KeysACS5T
    if /i "%userinp%"=="D" goto InstructionsACS5T
    if /i "%userinp%"=="E" goto MAINMENU
    if /i "%userinp%"=="F" goto End
    echo.Try Again...
    GOTO CHOOSEACTION3
    
    :InstallACS5T
    CLS
    SET hosts=%windir%\system32\drivers\etc\hosts
    findstr /i "3dns-2.adobe.com" %hosts% >nul
    IF %ERRORLEVEL% EQU 0 (
    echo ACS5T is already installed...
    ping -n 5 127.0.0.1 >nul
    goto ACS5T
    )
    attrib -r %hosts%
    echo. >>%hosts%
    FOR %%A IN (
    3dns-2.adobe.com
    3dns-3.adobe.com
    activate.adobe.com
    activate.wip3.adobe.com
    activate-sea.adobe.com
    activate-sjc0.adobe.com
    adobe-dns.adobe.com
    adobe-dns-2.adobe.com
    adobe-dns-3.adobe.com
    adobeereg.com
    ereg.adobe.com
    ereg.wip3.adobe.com
    hl2rcv.adobe.com
    practivate.adobe.com
    wip3.adobe.com
    wwis-dubc1-vip60.adobe.com
    www.adobeereg.com
    ) DO (
     echo 127.0.0.1 %%A >>%hosts%
    )
    attrib +r %hosts%
    echo ACS5T has been successfully installed...
    ping -n 5 127.0.0.1 >nul
    GOTO ACS5T
    
    :UninstallACS5T
    CLS
    SET hosts=%windir%\system32\drivers\etc\hosts
    findstr /i "3dns-2.adobe.com" %hosts% >nul
    IF %ERRORLEVEL% NEQ 0 (
    echo ACS5T is already uninstalled...
    ping -n 5 127.0.0.1 >nul
    goto ACS5T
    )
    attrib -r %hosts%
    FOR %%A IN (
    3dns-2.adobe.com
    3dns-3.adobe.com
    activate.adobe.com
    activate.wip3.adobe.com
    activate-sea.adobe.com
    activate-sjc0.adobe.com
    adobe-dns.adobe.com
    adobe-dns-2.adobe.com
    adobe-dns-3.adobe.com
    adobeereg.com
    ereg.adobe.com
    ereg.wip3.adobe.com
    hl2rcv.adobe.com
    practivate.adobe.com
    wip3.adobe.com
    wwis-dubc1-vip60.adobe.com
    www.adobeereg.com
    ) DO (
     MOVE %hosts% hosts.bak >NUL
     FINDSTR /V /C:"%%A" hosts.bak > %hosts%
     DEL /F /Q hosts.bak
    ) 
    attrib +r %hosts%
    echo ACS5T has been successfully uninstalled...
    ping -n 5 127.0.0.1 >nul
    GOTO ACS5T
    
    :KeysACS5T
    mode con: cols=45 lines=33
    echo Enter one of these keys
    echo.
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo XXXX-XXXX-XXXX-XXXX-XXXX-XXXX
    echo.
    pause
    GOTO ACS5T
    
    :InstructionsACS5T
    mode con: cols=89 lines=17
    echo 1. Sign up at http://www.adobe.com/products/creativesuite/mastercollection/ 
    echo.
    echo 2. Remember your ID and password then download the free trial for Master Collection
    echo.
    echo 3. Use ACS5T and click install first before you install your CS5 Master Collection
    echo.
    echo 4. Uncompress Adobe CS5 Master Collection 7-zip file with 7-zip or winrar
    echo.
    echo 5. Click Set-up file
    echo.
    echo 6. Click keys in ACS5T and select one
    echo.
    echo 7. Enter your ID and password then after you install Adobe CS5 Master Collection open up an application like photoshop or illustrator and click the help tab and re-register with your ID and password as many times as it takes until you recieve no more messages
    echo.
    pause
    GOTO ACS5T
    
    :End
    exit
     
  3. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    Thank you for sharing but the code I have now works fine
     
  4. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #144 timesurfer, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    I haven't tried it cause I'd have to uninstall office...lol However seems if someone is trying to install IORRT without office 2010 installed that is pretty silly. Curious what error IORRT pulls up when 2010 is not installed. Even more interesting is to be able to detect if someone is trying to use IORRT on retail 2010 which IORRT is not suppose to work cause of immediate nags

    And the credit for those variables is to cody and his old toolkit in batch form that he was not using anymore thus he donated to the IORRT project

    Error checking is fine however for IORRT and when working I could include in Trilogy 2.0
     
  5. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    I know it was for the: "The Official Batch File Repository - Learn & ask questions about batch files" ,thought it may be useful for the next man :)
     
  6. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    It is I appreciate it ;)
     
  7. chnix

    chnix MDL Member

    May 16, 2010
    147
    71
    10
    #147 chnix, Mar 1, 2011
    Last edited: Mar 1, 2011
    Ok. I will study some scripts and try to implement error checking solutions.

    Thanks for your opinion.
     
  8. chnix

    chnix MDL Member

    May 16, 2010
    147
    71
    10
    #148 chnix, Mar 2, 2011
    Last edited by a moderator: Apr 20, 2017
    @timesurfer

    With respect to detect if someone is trying to use IORRT on retail 2010, i think i found a solution (additions in red and removals in blue):
    Code:
    :IORRT
    @color 0A
    title IORRT 3.5
    
    REM Variables
    set InstallRoot=
    set OfficeArchType=
    
    REM Check Office Architecture Type
    if '%processor_architecture%'=='x86' Set OfficeArchType=32 && Goto:EndArchCheck
    goto:WOWCheck
    
    :WOWCheck
    2>nul REG QUERY HKLM\SOFTWARE\Microsoft\Office\14.0\Common | find /i "InstallRoot" 1>nul
    IF ERRORLEVEL 1 Set OfficeArchType=WOW && Goto:EndArchCheck
    Set OfficeArchType=64
    
    :EndArchCheck
    
    REM Get Office Installed Path
    if %OfficeArchType%==WOW (
    FOR /F "tokens=2* delims= " %%A IN ('"REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot" /v Path 2>NUL"') DO SET InstallRoot=%%B 
    if not defined InstallRoot ( cls & echo Office 2010 Not Installed! & echo. & pause & goto :mainmenu )
    Goto:FoundPath
    )
    FOR /F "tokens=2* delims= " %%A IN ('"REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot" /v Path 2>NUL"') DO SET InstallRoot=%%B
    if not defined InstallRoot ( cls & echo Office 2010 Not Installed! & echo. & pause & goto :mainmenu )
    
    cscript "%InstallRoot%"ospp.vbs /dstatus |FINDSTR /i "KMS_Client" >NUL
    if %errorlevel% EQU 1 ( cls & echo No Office 2010 Volume Products Found! & echo. & pause & goto :mainmenu )
    
    I will try do some tests and then report to you.
     
  9. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #149 timesurfer, Mar 2, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thanks I don't fell like uninstalling office right now to test but it looks like you are going to try to do two checks

    1. Is office installed
    2. Is retail installed

    Thank you and if you or I get this working then I will include in 2.0

    Again thanks
     
  10. chnix

    chnix MDL Member

    May 16, 2010
    147
    71
    10
    #150 chnix, Mar 2, 2011
    Last edited by a moderator: Apr 20, 2017
    You're welcome.

    1. I tried with Office Pro Plus and works fine.
    2. I'll try to test and report as soon as possible.

    By the way, i found another simple way to check admin:
    Code:
    sfc /? | FINDSTR /i "scannow" >NUL 2>&1
    if %errorlevel% == 1 ( echo Right click and run as administrator. & echo. & pause & exit )
    
    I think it works on XP too. I'll test as soon as possible.
     
  11. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #151 timesurfer, Mar 2, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Uh does my admin check not work on xp now? So if you want to just do office is not installed code first then if you feel like it then the retail check which would be impressive

    I think that would be final updates...lol I hope so I am so worn out over Trilogy :shisha:
     
  12. chnix

    chnix MDL Member

    May 16, 2010
    147
    71
    10
    I have no access to xp now. I believe that your check admin works perfectly on xp. I will install xp in a vm and test Trilogy on it. I talked about another method just for curious, just to add to the thread.
    Don't worry, you did a great job (with the collaboration of others also, of course).:worthy:

    Once i make the final tests (not installed, installed and retail) give you a feedback.

    Certainly be the final updates.:biggrin:
     
  13. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #153 timesurfer, Mar 2, 2011
    Last edited: Mar 2, 2011
    (OP)
    Boy I hope so :eek:

    But if working on Trilogy lets take it Trilogy thread so people can see your contribution in the thread in it's final development
     
  14. chnix

    chnix MDL Member

    May 16, 2010
    147
    71
    10
    #154 chnix, Mar 3, 2011
    Last edited by a moderator: Apr 20, 2017
    To the thread:
    Code:
    sfc /? | FINDSTR /i "scannow" >NUL 2>&1
    if %errorlevel% == 1 ( echo Right click and run as administrator. & echo. & pause & exit )
    The code above does not work on XP. Works fine on Seven.
     
  15. Compo

    Compo MDL Member

    Mar 29, 2011
    136
    106
    10
    #155 Compo, Mar 30, 2011
    Last edited by a moderator: Apr 20, 2017
    How's this?
    Code:
    @ECHO OFF&SETLOCAL ENABLEEXTENSIONS
    IF %2' EQU ' (SET N=%~1)
    IF NOT DEFINED N (ENDLOCAL&GOTO :EOF)
    IF "%N%" NEQ "%N:~,1%" (ENDLOCAL&GOTO :EOF)
    (ECHO=%N%|FINDSTR [1-9]>NUL 2>&1)||(ENDLOCAL&GOTO :EOF)
    SETLOCAL ENABLEDELAYEDEXPANSION
    FOR /L %%A IN (0,1,%N%) DO CALL SET R= !R! %%A
    FOR /L %%A IN (%N%,-1,0) DO (IF %%A EQU %N% (SET/A "E=N*2"&SET "B="
    SET "E=,-!E!") ELSE (IF %%A EQU 0 (SET "B=%N%"&SET "E="
    ) ELSE (SET/A "E=2*%%A"&SET/A "B=N-%%A"&SET "E=,-!E!"))
     CALL ECHO=%%R:~!B!!E!%%)
    FOR /L %%A IN (0,1,%N%) DO (IF %%A EQU %N% (SET/A "E=N*2"& SET "B="
    SET "E=,-!E!") ELSE (IF %%A EQU 0 (SET "B=%N%"&SET "E="
    ) ELSE (SET/A "E=2*%%A"&SET/A "B=N-%%A"&SET "E=,-!E!"))
     CALL ECHO=%%R:~!B!!E!%%)
    PAUSE
     
  16. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #156 timesurfer, Mar 31, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Window just closes on me
     
  17. Compo

    Compo MDL Member

    Mar 29, 2011
    136
    106
    10
    #157 Compo, Mar 31, 2011
    Last edited: Mar 31, 2011
    What did you enter as your parameter?

    The window will close if any of the criteria in the 2nd, 4th or 5th lines are not fulfilled.
    i.e. No parameter, more than one parameter, a parameter which is not a single integer, a parameter which is zero.

    Basically you have to enter diamond(.cmd) followed by 1, 2, 3, 4, 5, 6, 7, 8 or 9.

    <edit />
    There are sixteen lines in total, please ensure that copy/paste or forum formatting has not changed the code provided. Below is an archive containing the script.

    View attachment Diamond.zip
     
  18. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    Bro why don't you just post working code or am I missing something...lol
     
  19. Compo

    Compo MDL Member

    Mar 29, 2011
    136
    106
    10
    As a Moderator here, I'd appreciate it if you could show a little less rudeness and provide a little more information.

    Let me know exactly what you are doing and how; without proper feedback how can you expect me to debug possible problems with code.

    The script I provided works perfectly well on English systems Windows XP x86 through Windows 7 x64, I have provided a tested version in the archive and given instructions on how to use it in my previous post.

    Below is another explanation of usage.

    Example usage
    Extract the script in the archive to somewhere you can navigate to in a 'command prompt' session, e.g. your Desktop, then invoke one of the following commands:
    Desktop\Diamond.cmd 1
    Desktop\Diamond.cmd 2
    Desktop\Diamond.cmd 3
    Desktop\Diamond.cmd 4
    Desktop\Diamond.cmd 5
    Desktop\Diamond.cmd 6
    Desktop\Diamond.cmd 7
    Desktop\Diamond.cmd 8
    Desktop\Diamond.cmd 9
     
  20. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    As a moderator here I wasn't being rude just direct

    I started this thread and was only one to test your "code" so maybe you could recognize that instead of mis-percieving my simple inquiry as "rude"...lol

    Shouldn't I just be able to run as admin and diamond gets created in cmd prompt?

    I think MasterDisaster probably infered that this test happen by simply running .bat or .cmd file

    If the diamond is going to be bigger than default size then I might add a larger size console to compensate

    Look forward to it working for me ;)