admin 发表于 2026-8-31 00:17:47

Linux一键搭建KMS服务器脚本及激活Windows和Office

CentOS,Redhat,Fedora等请选择CentOS脚本

<font size="2" face="Tahoma">#! /bin/bash

#One-key-kms script by Dakkidaze <gioku@docomo.net.cn>

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear
start(){
yum install gcc git make -y
mkdir /usr/local/kms
cd /usr/local/kms
git clone https://github.com/Wind4/vlmcsd.git
cd vlmcsd
make
cd bin
mv vlmcsd /usr/local/kms/kms
cd /usr/local/kms/
rm -rf ./vlmcsd/
mv kms vlmcsd
clear
echo "Succeeded."
echo "The executable file lies in /usr/local/kms/"
echo "Remember that the server is not running right now."
echo "Please use -h to find possible usage for the executable or visit vlmcsd on Github."
echo "https://github.com/Wind4/vlmcsd"
echo "Addtionally, you may want to get a script to manage it."
echo "In this case, you may download a script at the one-key-kms repository."
echo "Thanks for your using!"
echo "Dakkidaze <gioku@docomo.net.cn>"
}
echo "This script will automatically download and compile KMS Server program for you."
echo "For more information, please visit https://github.com/Wind4/vlmcsd"
echo "Scrpit written by Dakkidaze <gioku@docomo.net.cn>"
echo "READY TO START?"
read -p "y/n:" choice
case $choice in
      "y")
      start
      ;;
      "n")
      exit 0;
      ;;
      *)
      echo "Please enter y or n!"
      ;;
esac
</font>Debian,Ubuntu,Mint等请选择Debian脚本

<font size="2" face="Tahoma">#! /bin/bash

#One-key-kms script by Dakkidaze <gioku@docomo.net.cn>

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear
start(){
apt-get install gcc git make -y
mkdir /usr/local/kms
cd /usr/local/kms
git clone https://github.com/Wind4/vlmcsd.git
cd vlmcsd
make
cd bin
mv vlmcsd /usr/local/kms/kms
cd /usr/local/kms/
rm -rf ./vlmcsd/
mv kms vlmcsd
clear
echo "Succeeded."
echo "The executable file lies in /usr/local/kms/"
echo "Remember that the server is not running right now."
echo "Please use -h to find possible usage for the executable or visit vlmcsd on Github."
echo "https://github.com/Wind4/vlmcsd"
echo "Addtionally, you may want to get a script to manage it."
echo "In this case, you may download a script at the one-key-kms repository."
echo "Thanks for your using!"
echo "Dakkidaze <gioku@docomo.net.cn>"
}
echo "This script will automatically download and compile KMS Server program for you."
echo "For more information, please visit https://github.com/Wind4/vlmcsd"
echo "Scrpit written by Dakkidaze <gioku@docomo.net.cn>"
echo "READY TO START?"
read -p "y/n:" choice
case $choice in
      "y")
      start
      ;;
      "n")
      exit 0;
      ;;
      *)
      echo "Please enter y or n!"
      ;;
esac
</font>启动KMS

<font size="2" face="Tahoma">#!/bin/bash
# Author: Dakkidaze <gioku@docomo.net.cn>

DAEMON=/usr/local/kms/vlmcsd
STAT=2
check_running(){
PID=`ps -ef | grep -v grep | grep -i "vlmcsd" | awk '{print $2}'`
       if [ ! -z $PID ]; then
      STAT=0
    else
      STAT=1
    fi
}

do_restart() {
      check_running
      if [ $STAT = 0 ]; then
                echo "Restarting KMS Server..."
                kill $PID
      elif [ $STAT = 1 ]; then
                echo "Not started, starting now"
      fi
      $DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
      check_running
      if [ $STAT = 0 ]; then
                echo "Succeeded."
      elif [ $STAT = 1 ]; then
                echo "Failed."
      fi
}
do_stop() {
      check_running
      if [ $STAT = 0 ]; then
                echo "Shutting down KMS Server..."
                kill $PID
                check_running
                if [ $STAT = 0 ]; then
                        echo "Failed."
                elif [ $STAT = 1 ]; then
                        echo "Succeeded."
                fi
      elif [ $STAT = 1 ]; then
                echo "Not running, no kill."
      fi
}
do_status() {
      check_running
      if [ $STAT = 0 ]; then
                echo "KMS Server is running."
      elif [ $STAT = 1 ]; then
                echo "KMS Server is not running."
      fi
}

do_start() {
      check_running
      if [ $STAT = 0 ]; then
                echo "KMS Server is already running."
                exit 0;
      elif [ $STAT = 1 ]; then
                echo "KMS Server is not running, starting now..."
      $DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
      fi
      check_running
      if [ $STAT = 0 ]; then
                echo "Succeeded."
      elif [ $STAT = 1 ]; then
                echo "Failed."
      fi
}

case "$1" in
    start|stop|restart|status)
    do_$1
    ;;
    *)
    echo "Usage: $0 start | stop | restart | status "
    ;;
esac
</font>./kms.sh start

激活 Windows系统需要是 VL 版本的,然后使用管理员权限运行 cmd,运行以下命令:
cd /d "%SystemRoot%\system32"slmgr /skms ip#ip为你KMS的IP地址或者域名 slmgr /atoslmgr /xpr

激活 Office首先你的 Office 必须是 VOL 版本,否则无法激活。
找到你的 Office 安装目录,如果你不知道你的 Office 装在哪个目录,可以鼠标右键一个程序图标比如 Word,然后选择 “打开文件所在的位置”,在上面地址栏就可以看到了。
这里以 Office2016 为例,32 位文件夹目录为 C:\Program Files (x86)\Microsoft Office\Office16。62 位目录为 C:\Program Files\Microsoft Office\Office16。关于文件夹对应的版本说明:Office16 是 Office2016,Office15 就是 Office2013,Office14 就是 Office2010。
下面以 32 位为参考。使用管理员权限运行 cmd,运行以下命令:
#进入Office文件夹执行命令
cd "C:\Program Files (x86)\Microsoft Office\Office16"cscript ospp.vbs /sethst:ip#ip为你KMS的IP地址或者域名cscript ospp.vbs /act
如果提示看到 successful 的字样,那么就是激活成功了,重新打开 Office 就好

页: [1]
查看完整版本: Linux一键搭建KMS服务器脚本及激活Windows和Office