admin 管理员组

文章数量: 887021

参照https://blog.csdn/kongxx/article/details/80630124

公司使用的是正版kms激活,但是每180天要激活一次也是麻烦,把激活脚本添加到计划任务实现开机自动执行,

附上脚本内容

添加开机自动执行kms批处理:

schtasks.exe /create /tn "kmsoffice" /ru SYSTEM /sc ONSTART /tr "C:\tools\office2010-2016.bat"

执行结果:

 

office kms脚本,可自动判断2010-2016

:office14
if exist "C:\Program Files\Microsoft Office\Office14\ospp.vbs" goto step1
if exist "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" goto step2
if exist "D:\Program Files\Microsoft Office\Office14\ospp.vbs" goto step7
if exist "D:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" goto step8
if exist "C:\Program Files\Microsoft Office\Office15\ospp.vbs" goto step3
if exist "C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" goto step4
if exist "D:\Program Files\Microsoft Office\Office15\ospp.vbs" goto step9
if exist "D:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" goto step10
if exist "C:\Program Files\Microsoft Office\Office16\ospp.vbs" goto step5
if exist "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" goto step6
if exist "D:\Program Files\Microsoft Office\Office16\ospp.vbs" goto step11
if exist "D:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" goto step12


goto tminst

:step1
echo 开始激活您系统中的office程序...
cscript "C:\Program Files\Microsoft Office\Office14\ospp.vbs" /sethst:192.168.1.144
cscript "C:\Program Files\Microsoft Office\Office14\ospp.vbs" /act
goto tminst

:step2
echo 开始激活您系统中的office程序...
cscript "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /sethst:192.168.1.144
cscript "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /act
goto tminst

:step3
echo 开始激活您系统中的office程序...
cscript "C:\Program Files\Microsoft Office\Office15\ospp.vbs" /sethst:192.168.1.144
cscript "C:\Program Files\Microsoft Office\Office15\ospp.vbs" /act
goto tminst

:step4
echo 开始激活您系统中的office程序...
cscript "C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" /sethst:192.168.1.144
cscript "C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" /act
goto tminst


:step5
echo 开始激活您系统中的office程序...
cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /sethst:192.168.1.144
cscript "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /act
goto tminst

:step6
echo 开始激活您系统中的office程序...
cscript "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /sethst:192.168.1.144
cscript "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /act
goto tminst


:step7
echo 开始激活您系统中的office程序...
cscript "D:\Program Files\Microsoft Office\Office14\ospp.vbs" /sethst:192.168.1.144
cscript "D:\Program Files\Microsoft Office\Office14\ospp.vbs" /act
goto tminst

:step8
echo 开始激活您系统中的office程序...
cscript "D:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /sethst:192.168.1.144
cscript "D:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /act
goto tminst

:step9
echo 开始激活您系统中的office程序...
cscript "D:\Program Files\Microsoft Office\Office15\ospp.vbs" /sethst:192.168.1.144
cscript "D:\Program Files\Microsoft Office\Office15\ospp.vbs" /act
goto tminst

:step10
echo 开始激活您系统中的office程序...
cscript "D:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" /sethst:192.168.1.144
cscript "D:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" /act
goto tminst

:step11
echo 开始激活您系统中的office程序...
cscript "D:\Program Files\Microsoft Office\Office16\ospp.vbs" /sethst:192.168.1.144
cscript "D:\Program Files\Microsoft Office\Office16\ospp.vbs" /act
goto tminst

:step12
echo 开始激活您系统中的office程序...
cscript "D:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /sethst:192.168.1.144
cscript "D:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" /act
goto tminst


:tminst

 

本文标签: 脚本 Windows schtasks officekms