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

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

  1. woebetide

    woebetide MDL Member

    May 28, 2007
    240
    78
    10
    #121 woebetide, Feb 28, 2011
    Last edited by a moderator: Apr 20, 2017
    Found this somewhere, don't know if this is of any help?
    Code:
    net user %username% | findstr /r Administrator.
    if %errorlevel% == 1 (
    echo This is not an admin account
    ) else (
    echo This is an admin account
    )
     
  2. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #122 timesurfer, Feb 28, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    So if it does work I will put in beginning of Trilogy?
     
  3. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    seems to work but it don't tell if the cmd has been run as admin, just run from admin.
     
  4. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    My idea is to just give msg if console hasn't then pause for 5 seconds and close otherwise commence to mainmenu. Kinda like a certain way to never see error

    Post where you put code cause I tried it as non-admin and it didn't work
     
  5. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    I just made a single .cmd;

    @echo off
    title test
    mode con: cols=51 lines=26
    net user %username% | findstr /r Administrator.
    if %errorlevel% == 1 (
    echo This is not an admin account
    pause
    ) else (
    echo This is an admin account
    pause
    )
    end

    and tried it on my desktop that's admin and on a vpc that has a non admin acc, tried it without the title and it shows just normal cmd title but run as admin shows admin title.

    [​IMG]
     
  6. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #126 timesurfer, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Code:
    @echo off
    title test 
    mode con: cols=51 lines=26
    net user %username% | findstr /r Administrator. >nul
    if %errorlevel%==0 (
    echo Right click and run Trilogy as administrator...
    ) else (
    goto mainmenu
    )
    :mainmenu
    echo Ran as administrator...
    pause
    Yea it doesn't work yet
     
  7. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #127 timesurfer, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Lets use this so when it does work it will go to main menu

    Code:
    @echo off
    :MAINMENU
    @color 0A
    title Trilogy 1.3
    mode con: cols=45 lines=9
    net user %username% | findstr /r Administrator. >nul
    if %errorlevel%==0 ( echo Right click and run Trilogy as administrator
    goto mainmenu
    )
    :mainmenu
    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.
     
  8. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    this worked;

    @echo off
    title test
    mode con: cols=51 lines=26
    net user %username% | findstr /r Administrator.
    if %errorlevel% == 1 (
    echo This is not an admin account
    pause
    ) else (
    echo this is an admin account
    goto mainmenu
    )
    :mainmenu
    echo Ran as administrator...
    pause
    end

    [​IMG]
     
  9. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    I believe it is doing both meaning as non-admin it still gives msg ran as admin

    tomah are you out there...lol
     
  10. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    it is, running the cmd from an admin account isn't running it as admin by right clicking and selecting run as, dont know the script to check if it has been run as admin but this works for checking account status, playing with cmd.exe I found that on a non admin account you need to enter a password to run as admin
     
  11. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    Well I appreciate you helping me
     
  12. tomah

    tomah MDL Senior Member

    Sep 25, 2010
    408
    355
    10
    #132 tomah, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    The code above will tell you if the current user that is logged in has administrator permissions. Unfortunately, that is not quite the same as if you "run as admin".

    I think a simple but rudimentary way to do what you want would be to execute a command which requires "run as admin", check for errors, then act accordingly.

    As I'm still XP, I cannot test this but let me know what happens when you try this bit of code:

    Code:
    @echo off
    md %windir%\TrilogyAdminTest
    if %errorlevel%==0 (
    rd %windir%\TrilogyAdminTest
    echo Ran as Admin
    goto end
    ) else (
    echo Please right click and run as admin
    )
    :end
    Assuming that creating a directory within the WINDOWS directory requires "run as admin", this should work. Of course the actual directory name can be anything you like.
     
  13. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #133 timesurfer, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    I tried it with this and both opened Trilogy

    Code:
    @echo off
    @color 0A
    title Trilogy 1.3
    mode con: cols=45 lines=9
    md %windir%\TrilogyAdminTest
    if %errorlevel%==0 (
    rd %windir%\TrilogyAdminTest
    echo Ran as Admin
    goto mainmenu
    ) else (
    echo Please right click and run as admin
    pause
    )
    :mainmenu
    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.
    This will be good for anyone wanting their script to always be run as admin
     
  14. tomah

    tomah MDL Senior Member

    Sep 25, 2010
    408
    355
    10
    Can you try just opening a cmd prompt and try creating a directory in "C:\Windows" (without running as admin). If this works, perhaps we need to try creating it in "C:\Windows\System32" or somewhere else. If I was on Win7, I could probably give you a better, more specific answer.
     
  15. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    perhaps using the if cmd to check if an app is running or a process is running can give the result looked for;

    [​IMG]
     
  16. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #136 timesurfer, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    This works I think...lol

    Code:
    @echo off
    @color 0A
    title Trilogy 1.3
    mode con: cols=45 lines=9
    md %windir%\TrilogyAdminTest
    if %errorlevel%==0 (
    rd %windir%\TrilogyAdminTest
    echo Ran as Admin
    goto mainmenu
    ) else (
    echo Right click Trilogy and run as administrator
    echo.
    pause
    goto end
    )
    :mainmenu
    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.
     
  17. tomah

    tomah MDL Senior Member

    Sep 25, 2010
    408
    355
    10
    #137 tomah, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    I didn't even notice the missing GOTO. Anyways, as long as it works. :shisha:
     
  18. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    I get this msg

    [​IMG]

    How do I get rid of access is denied msg...lol
     
  19. tomah

    tomah MDL Senior Member

    Sep 25, 2010
    408
    355
    10
    You should be able to 2>NUL it away on the MD line.
     
  20. timesurfer

    timesurfer MDL Developer

    Nov 22, 2009
    8,524
    4,112
    270
    #140 timesurfer, Mar 1, 2011
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Yea this works good

    [​IMG]

    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 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') DO SET InstallRoot=%%B 
    Goto:FoundPath
    )
    FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Common\InstallRoot" /v Path') DO SET InstallRoot=%%B
    
    :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
    Thanks again