Skip to content

Instantly share code, notes, and snippets.

@TaiNing1237
Created January 1, 2026 04:12
Show Gist options
  • Select an option

  • Save TaiNing1237/e3a53dc639f9e6e93b8cbe15bda5ec3a to your computer and use it in GitHub Desktop.

Select an option

Save TaiNing1237/e3a53dc639f9e6e93b8cbe15bda5ec3a to your computer and use it in GitHub Desktop.
Office 2024 MagicInstall Script
@echo off
setlocal
:: =========================================================
:: 重要:切換到腳本所在的資料夾
:: 這能解決 "找不到 xml" 或路徑錯誤的問題
:: =========================================================
cd /d "%~dp0"
:MENU
CLS
ECHO ========================================================
ECHO Office 2024 LTSC (Standard) - Automation Tool
ECHO ========================================================
ECHO.
ECHO [1] Install Office 2024 (Word, Excel, PPT Only)
ECHO [2] Uninstall Office 2024 (Clean Remove)
ECHO [3] Exit
ECHO.
ECHO ========================================================
SET /P M="> Please select an option (1-3): "
IF %M%==1 GOTO INSTALL
IF %M%==2 GOTO UNINSTALL
IF %M%==3 GOTO EOF
:INSTALL
CLS
ECHO [*] Generating Installation Config for Standard 2024...
:: 產生安裝設定檔 (已寫入 PIDKEY 和 Standard 版本)
(
echo ^<Configuration^>
echo ^<Add OfficeClientEdition="64" Channel="PerpetualVL2024"^>
echo ^<!-- 指定 Standard 版本與金鑰 --^>
echo ^<Product ID="Standard2024Volume" PIDKEY="V28N4-JG22K-W66P8-VTMGK-H6HGR"^>
echo ^<Language ID="zh-tw" /^>
echo ^<!-- 排除不需要的軟體,只留 Word/Excel/PPT --^>
echo ^<ExcludeApp ID="Access" /^>
echo ^<ExcludeApp ID="Lync" /^>
echo ^<ExcludeApp ID="Outlook" /^>
echo ^<ExcludeApp ID="OneNote" /^>
echo ^<ExcludeApp ID="Publisher" /^>
echo ^<ExcludeApp ID="OneDrive" /^>
echo ^<ExcludeApp ID="Visio" /^>
echo ^<ExcludeApp ID="Project" /^>
echo ^<ExcludeApp ID="Teams" /^>
echo ^</Product^>
echo ^</Add^>
echo ^<Display Level="Full" AcceptEULA="TRUE" /^>
echo ^<Property Name="AUTOACTIVATE" Value="1" /^>
echo ^<Property Name="FORCEAPPSHUTDOWN" Value="TRUE" /^>
echo ^</Configuration^>
) > install_config.xml
:: 稍微等待 2 秒確保檔案寫入完成
timeout /t 2 /nobreak >nul
ECHO [*] Config generated. Starting Installation...
IF EXIST "setup.exe" (
:: 使用絕對路徑 "%~dp0" 確保 setup.exe 找得到檔案
setup.exe /configure "%~dp0install_config.xml"
) ELSE (
ECHO [Error] setup.exe not found! Please download ODT first.
PAUSE
GOTO MENU
)
GOTO DONE
:UNINSTALL
CLS
ECHO [*] Generating Removal Config...
:: 產生移除專用的 XML
(
echo ^<Configuration^>
echo ^<Remove All="TRUE" /^>
echo ^<Display Level="Full" AcceptEULA="TRUE" /^>
echo ^<Property Name="FORCEAPPSHUTDOWN" Value="TRUE" /^>
echo ^</Configuration^>
) > remove_config.xml
:: 稍微等待 2 秒確保檔案寫入完成 (這是修復 "找不到檔案" 的關鍵)
timeout /t 2 /nobreak >nul
ECHO [*] Removal Config generated.
ECHO [!] WARNING: This will remove ALL Office products.
PAUSE
ECHO [*] Starting Uninstallation...
IF EXIST "remove_config.xml" (
:: 使用絕對路徑 "%~dp0" 確保 setup.exe 找得到檔案
setup.exe /configure "%~dp0remove_config.xml"
) ELSE (
ECHO [Error] remove_config.xml generation failed!
PAUSE
GOTO MENU
)
GOTO DONE
:DONE
ECHO.
ECHO ========================================================
ECHO Operation Completed!
ECHO ========================================================
PAUSE
GOTO MENU
:EOF
EXIT
@TaiNing1237
Copy link
Copy Markdown
Author

Office 2024 LTSC Installation Guide

Video Tutorial: [YouTube Video]

Author: ZerototheZerothPower (0^0)

This guide provides two methods to install a clean version of Office 2024 LTSC:

  1. The "Magic" Way: Using the automated batch script (Recommended).
  2. The Manual Way: Using official Microsoft documentation and command lines.

⚡ Option 1: The "Magic" Way (Recommended)

Use the MagicInstall.bat script to automate the configuration and installation process.

Prerequisites

  1. Download ODT: Search for "Office Deployment Tool" on Google (official Microsoft site).
  2. Extract: Run the downloaded tool and extract setup.exe to your folder (e.g., Office2024).

Steps

  1. Place setup.exe and MagicInstall.bat in the SAME folder.
  2. IMPORTANT: Right-click MagicInstall.bat and select "Run as Administrator".
  3. Follow the on-screen menu:
    • Press 1 to Install (Standard Edition).
    • Press 2 to Clean Uninstall (Reset Status).

🛠️ Option 2: The Manual SOP (Technical Reference)

Environment: Windows 11

Objective: Clean installation using manual configuration.

Phase 1: Preparation & Cleanup

  1. Remove Existing Installations: Ensure all previous versions of Microsoft Office are completely uninstalled.
  2. Create Workspace: Create a folder named Office2024.

Phase 2: Tool Retrieval

  1. Download ODT: Get the Office Deployment Tool from Microsoft.
  2. Extract Files: Run officedeploymenttool.exe. Extract to your Office2024 folder.Note: Keep setup.exe. You can safely delete the sample .xml files.

Phase 3: Configuration (OCT)

  1. Access OCT: Go to config.office.com.
  2. Define Architecture & Suite:
    • Architecture: 64-bit
    • Product: Office LTSC Standard 2024 - Volume License (Do NOT select Professional Plus).
  3. Select Applications: Choose only what you need (Word, Excel, PPT).
  4. Export: Click Export -> "Keep Current Settings" -> Save as config.xml.
  5. Consolidate: Move config.xml into the folder with setup.exe.

Phase 4: Deployment via PowerShell

  1. Launch Terminal: Right-click Start -> Terminal (Admin).

  2. Navigate:
    cd "C:\Path\To\Your\Office2024"

  3. Execute:
    .\setup.exe /configure .\config.xml

  4. Wait: Installation takes 5–10 minutes.

⚠️ Important Note on Licensing

This installation utilizes a Volume License channel (GVLK). Without a valid enterprise KMS server, the software will operate within a standard Grace Period.

  • If activation fails or expires, you can use the script (Option 1) to Uninstall (Option 2) and then Re-install (Option 1) to reset the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment