Skip to content

Instantly share code, notes, and snippets.

@QuiltMeow
Created February 9, 2024 14:44
Show Gist options
  • Select an option

  • Save QuiltMeow/fbd301eba54bb393d7bbf4f08aff6033 to your computer and use it in GitHub Desktop.

Select an option

Save QuiltMeow/fbd301eba54bb393d7bbf4f08aff6033 to your computer and use it in GitHub Desktop.
KMS Script
@echo off
title KMS Office 2019
>nul 2>&1 "%SystemRoot%\system32\cacls.exe" "%SystemRoot%\system32\config\system"
if "%ErrorLevel%" NEQ "0" (
echo 嘗試取得系統管理員權限 ...
goto UACPrompt
) else (
goto getAdmin
)
:UACPrompt
echo set UAC = CreateObject^("Shell.Application"^) > "%Temp%\GetAdmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runAs", 1 >> "%Temp%\GetAdmin.vbs"
"%Temp%\GetAdmin.vbs"
exit /b
:getAdmin
if exist "%Temp%\GetAdmin.vbs" (
del "%Temp%\GetAdmin.vbs"
)
pushd "%cd%"
cd /d "%~dp0"
cscript "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" /sethst:【KMS 伺服器 IP 位址】
cscript "%ProgramFiles%\Microsoft office\Office16\ospp.vbs" /setprt:1688
cscript "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" /act
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment