Created
May 1, 2024 10:05
-
-
Save abbodi1406/acba83a99c717aab0be7cd50504d3d99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@setlocal DisableDelayedExpansion | |
@echo off | |
@cls | |
set _args= | |
set _args=%* | |
if not defined _args goto :NoProgArgs | |
for %%A in (%_args%) do ( | |
if /i "%%A"=="-wow" set _rel1=1 | |
if /i "%%A"=="-arm" set _rel2=1 | |
) | |
:NoProgArgs | |
set "_cmdf=%~f0" | |
if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 ( | |
setlocal EnableDelayedExpansion | |
start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow" | |
exit /b | |
) | |
if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 ( | |
setlocal EnableDelayedExpansion | |
start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm" | |
exit /b | |
) | |
color 07 | |
title Check Activation Status [vbs] | |
set "SysPath=%SystemRoot%\System32" | |
set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\" | |
if exist "%SystemRoot%\Sysnative\reg.exe" ( | |
set "SysPath=%SystemRoot%\Sysnative" | |
set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%" | |
) | |
set "_bit=64" | |
set "_wow=1" | |
if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "_wow=0"&set "_bit=32" | |
set "_onat=HKLM\SOFTWARE\Microsoft\Office" | |
set "_owow=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office" | |
set "_cscript=cscript.exe //NoLogo" | |
set "_utemp=%TEMP%" | |
set "line2=************************************************************" | |
set "line3=____________________________________________________________" | |
set _sO16vbs=0 | |
set _sO15vbs=0 | |
for %%G in ( | |
"%ProgramFiles%" | |
"%ProgramW6432%" | |
"%ProgramFiles(x86)%" | |
) do if exist "%%~G\Microsoft Office\Office15\ospp.vbs" ( | |
set _sO15vbs=1 | |
) | |
set _WSH=1 | |
reg query "HKCU\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0) | |
reg query HKU\S-1-5-19 1>nul 2>nul && ( | |
reg query "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0) | |
) | |
if %_WSH% EQU 0 goto :casvWSH | |
if not exist "%SysPath%\vbscript.dll" goto :casvVBS | |
setlocal EnableDelayedExpansion | |
echo %line2% | |
echo *** Windows Status *** | |
echo %line2% | |
pushd "!_utemp!" | |
copy /y %SystemRoot%\System32\slmgr.vbs . >nul 2>&1 | |
net start sppsvc /y >nul 2>&1 | |
%_cscript% slmgr.vbs /dli || (echo Error executing slmgr.vbs&del /f /q slmgr.vbs&popd&goto :casVend) | |
%_cscript% slmgr.vbs /xpr | |
del /f /q slmgr.vbs >nul 2>&1 | |
popd | |
echo %line3% | |
:casVo16 | |
net start osppsvc /y >nul 2>&1 | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\16.0\Common\InstallRoot /v Path" 2^>nul') do if exist "%%b\EntityPicker.dll" set "office=%%b" | |
if exist "!office!\ospp.vbs" ( | |
set _sO16vbs=1 | |
echo. | |
echo %line2% | |
if %_sO15vbs% EQU 0 ( | |
echo *** Office 2016 %_bit%-bit Status *** | |
) else ( | |
echo *** Office 2013/2016 Status *** | |
) | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
if %_wow%==0 goto :casVo13 | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\16.0\Common\InstallRoot /v Path" 2^>nul') do if exist "%%b\EntityPicker.dll" set "office=%%b" | |
if exist "!office!\ospp.vbs" ( | |
set _sO16vbs=1 | |
echo. | |
echo %line2% | |
if %_sO15vbs% EQU 0 ( | |
echo *** Office 2016 32-bit Status *** | |
) else ( | |
echo *** Office 2013/2016 Status *** | |
) | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
:casVo13 | |
if %_sO16vbs% EQU 1 goto :casVo10 | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\15.0\Common\InstallRoot /v Path" 2^>nul') do if exist "%%b\EntityPicker.dll" set "office=%%b" | |
if exist "!office!\ospp.vbs" ( | |
echo. | |
echo %line2% | |
echo *** Office 2013 %_bit%-bit Status *** | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
if %_wow%==0 goto :casVo10 | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\15.0\Common\InstallRoot /v Path" 2^>nul') do if exist "%%b\EntityPicker.dll" set "office=%%b" | |
if exist "!office!\ospp.vbs" ( | |
echo. | |
echo %line2% | |
echo *** Office 2013 32-bit Status *** | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
:casVo10 | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\14.0\Common\InstallRoot /v Path" 2^>nul') do if exist "%%b\EntityPicker.dll" set "office=%%b" | |
if exist "!office!\ospp.vbs" ( | |
echo. | |
echo %line2% | |
echo *** Office 2010 %_bit%-bit Status *** | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
if %_wow%==0 goto :casVc16 | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\14.0\Common\InstallRoot /v Path" 2^>nul') do if exist "%%b\EntityPicker.dll" set "office=%%b" | |
if exist "!office!\ospp.vbs" ( | |
echo. | |
echo %line2% | |
echo *** Office 2010 32-bit Status *** | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
:casVc16 | |
reg query %_onat%\ClickToRun /v InstallPath >nul 2>&1 || ( | |
reg query %_owow%\ClickToRun /v InstallPath >nul 2>&1 || goto :casVc13 | |
) | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\ClickToRun /v InstallPath" 2^>nul') do (set "office=%%b\Office16") | |
if exist "!office!\ospp.vbs" ( | |
set _sO16vbs=1 | |
echo. | |
echo %line2% | |
if %_sO15vbs% EQU 0 ( | |
echo *** Office 2016+ C2R Status *** | |
) else ( | |
echo *** Office 2013+ Status *** | |
) | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
if %_wow%==0 goto :casVc13 | |
set office= | |
for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\ClickToRun /v InstallPath" 2^>nul') do (set "office=%%b\Office16") | |
if exist "!office!\ospp.vbs" ( | |
set _sO16vbs=1 | |
echo. | |
echo %line2% | |
if %_sO15vbs% EQU 0 ( | |
echo *** Office 2016+ C2R Status *** | |
) else ( | |
echo *** Office 2013+ Status *** | |
) | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
:casVc13 | |
if %_sO16vbs% EQU 1 goto :casVc10 | |
reg query %_onat%\15.0\ClickToRun /v InstallPath >nul 2>&1 || ( | |
reg query %_owow%\15.0\ClickToRun /v InstallPath >nul 2>&1 || goto :casVc10 | |
) | |
set office= | |
for %%G in ( | |
"%ProgramFiles%" | |
"%ProgramW6432%" | |
"%ProgramFiles(x86)%" | |
) do if exist "%%~G\Microsoft Office\Office15\ospp.vbs" ( | |
if not defined office set "office=%%~G\Microsoft Office\Office15\ospp.vbs" | |
) | |
if exist "!office!\ospp.vbs" ( | |
echo. | |
echo %line2% | |
echo *** Office 2013 C2R Status *** | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
:casVc10 | |
if %_wow%==0 reg query %_onat%\14.0\CVH /f Click2run /k >nul 2>&1 || goto :casVend | |
if %_wow%==1 reg query %_owow%\14.0\CVH /f Click2run /k >nul 2>&1 || goto :casVend | |
set office= | |
for %%G in ( | |
"%ProgramFiles%" | |
"%ProgramW6432%" | |
"%ProgramFiles(x86)%" | |
) do if exist "%%~G\Microsoft Office\Office14\ospp.vbs" ( | |
if not defined office set "office=%%~G\Microsoft Office\Office14\ospp.vbs" | |
) | |
if exist "!office!\ospp.vbs" ( | |
echo. | |
echo %line2% | |
echo *** Office 2010 C2R Status *** | |
echo %line2% | |
%_cscript% "!office!\ospp.vbs" /dstatus | |
) | |
goto :casVend | |
:casvVBS | |
echo ==== ERROR ==== | |
echo VBScript engine is not installed. | |
echo It is required for this script to work. | |
goto :casVend | |
:casvWSH | |
echo ==== ERROR ==== | |
echo Windows Script Host is disabled. | |
echo It is required for this script to work. | |
goto :casVend | |
:casVend | |
echo. | |
echo Press any key to exit. | |
pause >nul | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment