1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| @echo off
:: BatchGotAdmin :------------------------------------- REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin. 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 "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" exit /B
:gotAdmin pushd "%CD%" CD /D "%~dp0" :--------------------------------------
color 2F echo. echo. echo.1.Office 2010 激活 echo. echo.2.Office 2013 激活 echo. echo.3.Office 2016 激活 echo. echo.4.Office 2019/2021 激活 echo. echo.5.Windows 激活 echo. echo. set KMS_Server= set /p c=请输入数字并回车: if %c%==1 goto 1 if %c%==2 goto 2 if %c%==3 goto 3 if %c%==4 goto 4 if %c%==5 goto 5 :office setlocal EnableDelayedExpansion reg query %strRegKey% >nul 2>nul if %errorlevel%==0 (set strCurrentKey=%strRegKey%) else (set strCurrentKey=%strRegKey6432%) for /f "delims=" %%i in ('reg query %strCurrentKey%') do ( set strInstPath=%%i set strInstPath=!strInstPath:*REG_SZ=! ) :LTrim if "%strInstPath:~0,1%"==" " set "strInstPath=%strInstPath:~1%" && goto LTrim :RTrim if "%strInstPath:~-1%"==" " set "strInstPath=%strInstPath:~0,-1%" && goto RTrim if "%strInstPath:~-1%" neq "\" set strInstPath=%strInstPath%\ echo office安装目录为%strInstPath% cd /d %strInstPath% cscript ospp.vbs /sethst:%KMS_Server% cscript ospp.vbs /setprt:1688 cscript ospp.vbs /act pause exit :office2019 cscript ospp.vbs /sethst:%KMS_Server% cscript ospp.vbs /setprt:1688 cscript ospp.vbs /act pause exit
:1 set "strRegKey=HKEY_LOCAL_MACHINE\Software\Microsoft\Office\14.0\Common\InstallRoot /v Path" set "strRegKey6432=HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\14.0\Common\InstallRoot /v Path" goto office
:2 set "strRegKey=HKEY_LOCAL_MACHINE\Software\Microsoft\Office\15.0\Common\InstallRoot /v Path" set "strRegKey6432=HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\15.0\Common\InstallRoot /v Path" goto office
:3 set "strRegKey=HKEY_LOCAL_MACHINE\Software\Microsoft\Office\16.0\Common\InstallRoot /v Path" set "strRegKey6432=HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Office\16.0\Common\InstallRoot /v Path" goto office
:4 (if exist "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles%\Microsoft Office\Office16")&(if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles(x86)%\Microsoft Office\Office16")&(for /f %%x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)&(for /f %%x in ('dir /b ..\root\Licenses16\ProPlus2019VL*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul) goto office2019
:5 cscript "%SystemRoot%\system32\slmgr.vbs" /skms %KMS_Server% cscript "%SystemRoot%\system32\slmgr.vbs" -ato pause exit
|