系列文章:
由於彰化縣KMS將於2021年11月1日停止服務,資訊組就人仰馬翻要去處理電腦Windows與Office認證。希望能夠只要滑鼠點兩下,讓電腦開機時就完成Windows與Office雙認證,不需要資訊組再去處理。那如果想要電腦開機時就完成Windows與Office雙認證,也只要點兩下就好。
範例檔案下載,解壓密碼demo1234
教學影片
此外,針對縣網版本Office認證BAT,進行比對。發現chcoffice2016_kms.bat 與 chcoffice2019_kms.bat 的內容 只有6與9的差別。換言之,office2019的認證可以用chcoffice2016_kms.bat 進行認證。
目的:電腦開機自動完成彰化縣Office 與Windows KMS 雙認證
檔案名稱:AutoChcDoubleCerti.bat
內容:
檔案名稱:AutoChcDoubleCerti.bat
內容:
@echo off
REM ---------------以下是程式碼,不需更改---------------
REM :: BatchGotAdmin (Run as Admin code starts)
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"
echo UAC.ShellExecute "%~s0", "", "", "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"
REM :: BatchGotAdmin (Run as Admin code ends)
REM :: Your codes should start from the following line
REM -------------------關閉UAC------------------------
rem reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /d 0 /t REG_DWORD /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "ConsentPromptBehaviorAdmin" /d 0 /t REG_DWORD /f
gpupdate /force
taskkill /f /im explorer.exe
start %systemroot%\explorer
REM -------------------將縣網Win10認證複製到Startup------------------------
copy "%~dp0\KMS\chcwin10_kms.bat" "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
REM -------------------暫停2秒------------------------
timeout /t 2 /nobreak
REM -------------------判別Office版本------------------------
for /l %%a in (8,1,16) do (
for /f "tokens=*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Office\%%a.0\Word\Options" /v "PROGRAMDIR"') do (if not "%%i"=="" set Ever=%%a))
cls&echo %Ever%
echo %Ever%
if %Ever%==14 (goto office2010)
if %Ever%==15 (goto office2013)
if %Ever%==16 (goto office2016)
:office2010
copy "%~dp0\KMS\chcoffice2010_kms.bat" "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
shutdown /r /f /t 0
exit
:office2013
copy "%~dp0\KMS\chcoffice2013_kms.bat" "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
shutdown /r /f /t 0
exit
:office2016
copy "%~dp0\KMS\chcoffice2016_kms.bat" "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
shutdown /r /f /t 0
exit
目的:移除電腦開機自動完成彰化縣Office 與Windows KMS 雙認證
檔案名稱:RemoveAutoChcDoubleCerti.bat
內容:
檔案名稱:RemoveAutoChcDoubleCerti.bat
內容:
@echo off
REM ---------------以下是程式碼,不需更改---------------
REM :: BatchGotAdmin (Run as Admin code starts)
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"
echo UAC.ShellExecute "%~s0", "", "", "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"
REM :: BatchGotAdmin (Run as Admin code ends)
REM :: Your codes should start from the following line
REM -------------------開啟UAC------------------------
rem reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "ConsentPromptBehaviorAdmin" /d 5 /t REG_DWORD /f
gpupdate /force
taskkill /f /im explorer.exe
start %systemroot%\explorer
REM -------------------刪除Startup縣網Win10認證------------------------
del "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\chcwin10_kms.bat"
REM -------------------刪除Startup縣網Office認證------------------------
REM -------------------判別Office版本------------------------
for /l %%a in (8,1,16) do (
for /f "tokens=*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Office\%%a.0\Word\Options" /v "PROGRAMDIR"') do (if not "%%i"=="" set Ever=%%a))
cls&echo %Ever%
echo %Ever%
if %Ever%==14 (goto office2010)
if %Ever%==15 (goto office2013)
if %Ever%==16 (goto office2016)
:office2010
del "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\chcoffice2010_kms.bat"
shutdown /r /f /t 0
exit
:office2013
del "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\chcoffice2013_kms.bat"
shutdown /r /f /t 0
exit
:office2016
del "%HomePath%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\chcoffice2016_kms.bat"
shutdown /r /f /t 0
exit
資料來源:
沒有留言:
張貼留言