Need explanation on how this windows cmd batch script accomplishes the task of activating Microsoft Office 2016

6.2k views Asked by At

I do know that software piracy is a serious crime. Hence I am staying from that. But I came across a script which activates office 2016 using key Management Service(KMS) activation method.

But I am not completely sure how this script actually does that. Especially those lines involving >nul

EDIT: My doubts are what does those for loops and cscripts in the program do. As said by an user, if those are copied to a folder one up in the current directory, Why would it do that?

Does it kind of removing the files that are associated with license verification of the product?

Source: https://www.youtube.com/watch?v=Dq5khDs9ofk

@echo off
title Activate Microsoft Office 2016 ALL versions for FREE!&cls&echo ============================================================================
&echo #Project: Activating Microsoft software products for FREE without software&echo ============================================================================
&echo.&echo #Supported products:&echo - Microsoft Office Standard 2016&echo - Microsoft Office Professional Plus 2016&echo.&echo.

&(if exist "%ProgramFiles%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles%\Microsoft Office\Office16")
&(if exist "%ProgramFiles(x86)%\Microsoft Office\Office16\ospp.vbs" cd /d "%ProgramFiles(x86)%\Microsoft Office\Office16")

&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_kms*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)
&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_mak*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)
&echo.&echo ============================================================================

&echo Activating your Office...&cscript //nologo ospp.vbs /unpkey:WFG99 >nul&cscript //nologo ospp.vbs /unpkey:DRTFM >nul
&cscript //nologo ospp.vbs /unpkey:BTDRB >nul
&cscript //nologo ospp.vbs /unpkey:CPQVG >nul
&cscript //nologo ospp.vbs /inpkey:XQNVK-8JYDB-WJ9W3-YJ8YR-WFG99 >nul&set i=1
:server
if %i%==1 set KMS_Sev=kms4.MSGuides.com
if %i%==2 set KMS_Sev=kms5.MSGuides.com
if %i%==3 set KMS_Sev=kms6.MSGuides.com
if %i%==4 goto notsupported
cscript //nologo ospp.vbs /sethst:%KMS_Sev% >nul
&echo ============================================================================&echo.&echo.
cscript //nologo ospp.vbs /act | find /i "successful" && (echo.&echo ============================================================================&echo.&echo 
#My official blog: MSGuides.com&echo.&echo
#How it works: bit.ly/kms-server&echo.&echo 
#Please feel free to contact me at [email protected] if you have any questions or concerns.&echo.&echo 
#Please consider supporting this project: donate.msguides.com&echo
 #Your support is helping me keep my servers running everyday!&echo.&echo ============================================================================
 &choice /n /c YN /m "Would you like to visit my blog [Y,N]?" & if errorlevel 2 exit) || (echo The connection to my KMS server failed! Trying to connect to another one... 
 & echo Please wait... & echo. & echo. & set /a i+=1 & goto server)
explorer "http://MSGuides.com"&goto halt
:notsupported
echo.&echo ============================================================================&echo Sorry! Your version is not supported.&echo Please try installing the latest version here: bit.ly/getmsps
:halt
pause
1

There are 1 answers

0
Jason Faulkner On

I'm assuming you are referring to these lines:

&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_kms*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)
&(for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_mak*.xrm-ms') do cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul)

This being the case, here is what each part does:

for /f %%x in ('dir /b ..\root\Licenses16\proplusvl_kms*.xrm-ms')

Runs the dir /b command line tool (which will just list the file names) against the path ..\root\Licenses16\proplusvl_kms*.xrm-ms' which is:

  1. one folder up from the current directory
  2. root folder within this folder
  3. all file names matching the pattern proplusvl_kms*.xrm-ms within this folder

For each of these files, this command is run:

cscript ospp.vbs /inslic:"..\root\Licenses16\%%x" >nul

cscript is a Windows command which is used to execute Visual Basic Script files (vbs). In each iteration, %%x is replaced with the the respective value from the previous dir command results (which is a file name). So effective this runs the ospp.vbs passing in ..\root\Licenses16\[file name from 'dir'] as the parameter value for /inslic (which presumably the script understands).

The >nul simply redirects the output to nowhere instead of printing to the screen.