C2R-R2V-AIO.cmd 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597
  1. <!-- : Begin batch script
  2. @setlocal DisableDelayedExpansion
  3. @set uivr=v21
  4. @echo off
  5. :: change to 0 to keep Office C2R vNext license (subscription or lifetime)
  6. set vNextOverride=1
  7. :: change to 1 to enable debug mode
  8. set _Debug=0
  9. :: change to 0 to enable debug mode without cleaning or converting
  10. set _Cnvrt=1
  11. :: change to 1 to use VBScript to access WMI
  12. :: automatically enabled if wmic.exe is not installed
  13. set WMI_VBS=0
  14. :: change to 1 to use Windows PowerShell to access WMI
  15. :: automatically enabled if wmic.exe and VBScript are not installed
  16. set WMI_PS=0
  17. :: ##################################################################
  18. set _args=
  19. set _args=%*
  20. if not defined _args goto :NoProgArgs
  21. for %%A in (%*) do (
  22. if /i "%%A"=="-wow" set _rel1=1
  23. if /i "%%A"=="-arm" set _rel2=1
  24. )
  25. :NoProgArgs
  26. set "_cmdf=%~f0"
  27. if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
  28. setlocal EnableDelayedExpansion
  29. start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow "
  30. exit /b
  31. )
  32. if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
  33. setlocal EnableDelayedExpansion
  34. start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm "
  35. exit /b
  36. )
  37. set "SysPath=%SystemRoot%\System32"
  38. set "Path=%SystemRoot%\System32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\"
  39. if exist "%SystemRoot%\Sysnative\reg.exe" (
  40. set "SysPath=%SystemRoot%\Sysnative"
  41. set "Path=%SystemRoot%\Sysnative;%SystemRoot%;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%"
  42. )
  43. set "_ln============================================================="
  44. set "_err===== ERROR ===="
  45. set "_psc=powershell -nop -c"
  46. if /i "%PROCESSOR_ARCHITECTURE%"=="amd64" set "xBit=x64"&set "xOS=x64"
  47. if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set "xBit=x86"&set "xOS=A64"
  48. if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "xBit=x86"&set "xOS=x86"
  49. if /i "%PROCESSOR_ARCHITEW6432%"=="amd64" set "xBit=x64"&set "xOS=x64"
  50. if /i "%PROCESSOR_ARCHITEW6432%"=="arm64" set "xBit=x86"&set "xOS=A64"
  51. set winbuild=1
  52. for /f "tokens=6 delims=[]. " %%# in ('ver') do set winbuild=%%#
  53. set _cwmi=0
  54. for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
  55. cmd /c "wmic path Win32_ComputerSystem get CreationClassName /value" 2>nul | find /i "ComputerSystem" 1>nul && set _cwmi=1
  56. )
  57. set _pwsh=1
  58. for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" set _pwsh=0
  59. if not exist "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" set _pwsh=0
  60. 2>nul %_psc% $ExecutionContext.SessionState.LanguageMode | find /i "Full" 1>nul || set _pwsh=0
  61. if %_Cnvrt% NEQ 1 set _Debug=1
  62. set _fC2R=TheEnd
  63. set "_Null=1>nul 2>nul"
  64. set "_temp=%SystemRoot%\Temp"
  65. reg.exe query HKU\S-1-5-19 %_Null% || goto :E_Admin
  66. :Passed
  67. if not exist "%_temp%\" mkdir "%_temp%" %_Null%
  68. set "_onat=HKLM\SOFTWARE\Microsoft\Office"
  69. set "_owow=HKLM\SOFTWARE\WOW6432Node\Microsoft\Office"
  70. set "_batf=%~f0"
  71. set "_batp=%_batf:'=''%"
  72. set "_Local=%LocalAppData%"
  73. set "_log=%~dpn0"
  74. set "_work=%~dp0"
  75. if "%_work:~-1%"=="\" set "_work=%_work:~0,-1%"
  76. for /f "skip=2 tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do call set "_dsk=%%b"
  77. if exist "%PUBLIC%\Desktop\desktop.ini" set "_dsk=%PUBLIC%\Desktop"
  78. set _WSH=1
  79. reg query "HKCU\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
  80. reg query "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
  81. if %_cwmi% EQU 0 if %WMI_PS% EQU 0 if %_WSH% EQU 1 if exist "%SysPath%\vbscript.dll" set WMI_VBS=1
  82. if %_cwmi% EQU 0 if %WMI_VBS% EQU 0 if %_pwsh% EQU 1 set WMI_PS=1
  83. if %_cwmi% EQU 0 if %WMI_VBS% EQU 0 if %WMI_PS% EQU 0 goto :E_WMI
  84. if %WMI_VBS% NEQ 0 if %WMI_PS% EQU 0 (
  85. if %_WSH% EQU 0 goto :E_WSH
  86. if not exist "%SysPath%\vbscript.dll" goto :E_VBS
  87. set _cwmi=0
  88. )
  89. if %WMI_PS% NEQ 0 (
  90. if %_pwsh% EQU 0 goto :E_PWS
  91. set _cwmi=0
  92. set WMI_VBS=0
  93. )
  94. set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
  95. set "_csm=cscript.exe //NoLogo //Job:WmiMethod "%~nx0?.wsf""
  96. set "_csp=cscript.exe //NoLogo //Job:WmiPKey "%~nx0?.wsf""
  97. setlocal EnableDelayedExpansion
  98. copy /y nul "!_work!\#.rw" %_Null% && (
  99. if exist "!_work!\#.rw" del /f /q "!_work!\#.rw"
  100. ) || (
  101. set "_log=!_dsk!\%~n0"
  102. )
  103. pushd "!_work!"
  104. if %_Debug% EQU 0 (
  105. set "_Nul1=1>nul"
  106. set "_Nul2=2>nul"
  107. set "_Nul6=2^>nul"
  108. set "_Nul3=1>nul 2>nul"
  109. call :Begin
  110. ) else (
  111. set "_Nul1="
  112. set "_Nul2="
  113. set "_Nul6="
  114. set "_Nul3="
  115. echo.
  116. echo Running in Debug Mode...
  117. echo The window will be closed when finished
  118. echo.
  119. echo writing debug log to:
  120. echo "!_log!_Debug.log"
  121. @echo on
  122. @prompt $G
  123. @call :Begin >"!_log!_tmp.log" 2>&1 &cmd /u /c type "!_log!_tmp.log">"!_log!_Debug.log"&del "!_log!_tmp.log"
  124. )
  125. @color 07
  126. @title %ComSpec%
  127. @echo off
  128. @exit /b
  129. :Begin
  130. @color 1F
  131. set "_title=Office Click-to-Run Retail-to-Volume %uivr%"
  132. title %_title%
  133. set "_SLMGR=%SysPath%\slmgr.vbs"
  134. set "_oApp=0ff1ce15-a989-479d-af46-f275c6370663"
  135. if %_Debug% EQU 0 (
  136. set "_cscript=cscript.exe //NoLogo //B"
  137. ) else (
  138. set "_cscript=cscript.exe //NoLogo"
  139. )
  140. set _LTS19=0
  141. set _LTS21=0
  142. set _LTS24=0
  143. set "_tag="&set "_ons= 2016"
  144. echo %_ln%
  145. echo Running C2R-R2V %uivr%
  146. echo %_ln%
  147. if %winbuild% LSS 7601 (
  148. set "msg=Windows 7 SP1 is the minimum supported OS"
  149. goto :%_fC2R%
  150. )
  151. sc query ClickToRunSvc %_Nul3%
  152. set error1=%errorlevel%
  153. sc query OfficeSvc %_Nul3%
  154. set error2=%errorlevel%
  155. if %error1% EQU 1060 if %error2% EQU 1060 (
  156. set "msg=Office C2R service is not detected"
  157. goto :%_fC2R%
  158. )
  159. set _Office16=0
  160. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (
  161. set _Office16=1
  162. )
  163. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses16\ProPlus*.xrm-ms" (
  164. set _Office16=1
  165. )
  166. set _Office15=0
  167. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\15.0\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (
  168. set _Office15=1
  169. )
  170. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\15.0\ClickToRun /v InstallPath" %_Nul6%') do if exist "%%b\root\Licenses\ProPlus*.xrm-ms" (
  171. set _Office15=1
  172. )
  173. if %_Office16% EQU 0 if %_Office15% EQU 0 (
  174. set "msg=Office C2R InstallPath is not detected"
  175. goto :%_fC2R%
  176. )
  177. :Reg16istry
  178. if %_Office16% EQU 0 goto :Reg15istry
  179. set "_InstallRoot="
  180. set "_ProductIds="
  181. set "_GUID="
  182. set "_Config="
  183. set "_PRIDs="
  184. set "_LicensesPath="
  185. set "_Integrator="
  186. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\ClickToRun /v InstallPath" %_Nul6%') do (set "_InstallRoot=%%b\root")
  187. if not "%_InstallRoot%"=="" (
  188. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\ClickToRun /v InstallPath" %_Nul6%') do (set "_OSPPVBS=%%b\Office16\OSPP.VBS")
  189. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\ClickToRun /v PackageGUID" %_Nul6%') do (set "_GUID=%%b")
  190. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_ProductIds=%%b")
  191. set "_Config=%_onat%\ClickToRun\Configuration"
  192. set "_PRIDs=%_onat%\ClickToRun\ProductReleaseIDs"
  193. ) else (
  194. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\ClickToRun /v InstallPath" %_Nul6%') do (set "_InstallRoot=%%b\root")
  195. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\ClickToRun /v InstallPath" %_Nul6%') do (set "_OSPPVBS=%%b\Office16\OSPP.VBS")
  196. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\ClickToRun /v PackageGUID" %_Nul6%') do (set "_GUID=%%b")
  197. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_ProductIds=%%b")
  198. set "_Config=%_owow%\ClickToRun\Configuration"
  199. set "_PRIDs=%_owow%\ClickToRun\ProductReleaseIDs"
  200. )
  201. set "_LicensesPath=%_InstallRoot%\Licenses16"
  202. set "_Integrator=%_InstallRoot%\integration\integrator.exe"
  203. for /f "skip=2 tokens=2*" %%a in ('"reg query %_PRIDs% /v ActiveConfiguration" %_Nul6%') do set "_PRIDs=%_PRIDs%\%%b"
  204. if "%_ProductIds%"=="" (
  205. if %_Office15% EQU 0 (set "msg=Office C2R ProductIDs are not detected"&goto :%_fC2R%) else (goto :Reg15istry)
  206. )
  207. if not exist "%_LicensesPath%\ProPlus*.xrm-ms" (
  208. if %_Office15% EQU 0 (set "msg=Office C2R Licenses files are not detected"&goto :%_fC2R%) else (goto :Reg15istry)
  209. )
  210. if not exist "%_Integrator%" (
  211. if %_Office15% EQU 0 (set "msg=Office C2R Licenses Integrator is not detected"&goto :%_fC2R%) else (goto :Reg15istry)
  212. )
  213. if exist "%_LicensesPath%\Word2019VL_KMS_Client_AE*.xrm-ms" (set _LTS19=1&set "_tag=2019"&set "_ons= 2019")
  214. if exist "%_LicensesPath%\Word2021VL_KMS_Client_AE*.xrm-ms" (set _LTS21=1)
  215. if exist "%_LicensesPath%\Word2024VL_KMS_Client_AE*.xrm-ms" (set _LTS24=1)
  216. if %winbuild% LSS 10240 if !_LTS21! EQU 1 (set "_tag=2021"&set "_ons= 2021")
  217. if %_Office15% EQU 0 goto :CheckC2R
  218. :Reg15istry
  219. set "_Install15Root="
  220. set "_Product15Ids="
  221. set "_Con15fig="
  222. set "_PR15IDs="
  223. set "_OSPP15Ready="
  224. set "_Licenses15Path="
  225. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\15.0\ClickToRun /v InstallPath" %_Nul6%') do (set "_Install15Root=%%b\root")
  226. if not "%_Install15Root%"=="" (
  227. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\15.0\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_Product15Ids=%%b")
  228. set "_Con15fig=%_onat%\15.0\ClickToRun\Configuration /v ProductReleaseIds"
  229. set "_PR15IDs=%_onat%\15.0\ClickToRun\ProductReleaseIDs"
  230. set "_OSPP15Ready=%_onat%\15.0\ClickToRun\Configuration"
  231. ) else (
  232. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\15.0\ClickToRun /v InstallPath" %_Nul6%') do (set "_Install15Root=%%b\root")
  233. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\15.0\ClickToRun\Configuration /v ProductReleaseIds" %_Nul6%') do (set "_Product15Ids=%%b")
  234. set "_Con15fig=%_owow%\15.0\ClickToRun\Configuration /v ProductReleaseIds"
  235. set "_PR15IDs=%_owow%\15.0\ClickToRun\ProductReleaseIDs"
  236. set "_OSPP15Ready=%_owow%\15.0\ClickToRun\Configuration"
  237. )
  238. set "_OSPP15ReadT=REG_SZ"
  239. if "%_Product15Ids%"=="" (
  240. reg query %_onat%\15.0\ClickToRun\propertyBag /v productreleaseid %_Nul3% && (
  241. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\15.0\ClickToRun\propertyBag /v productreleaseid" %_Nul6%') do (set "_Product15Ids=%%b")
  242. set "_Con15fig=%_onat%\15.0\ClickToRun\propertyBag /v productreleaseid"
  243. set "_OSPP15Ready=%_onat%\15.0\ClickToRun"
  244. set "_OSPP15ReadT=REG_DWORD"
  245. )
  246. reg query %_owow%\15.0\ClickToRun\propertyBag /v productreleaseid %_Nul3% && (
  247. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\15.0\ClickToRun\propertyBag /v productreleaseid" %_Nul6%') do (set "_Product15Ids=%%b")
  248. set "_Con15fig=%_owow%\15.0\ClickToRun\propertyBag /v productreleaseid"
  249. set "_OSPP15Ready=%_owow%\15.0\ClickToRun"
  250. set "_OSPP15ReadT=REG_DWORD"
  251. )
  252. )
  253. set "_Licenses15Path=%_Install15Root%\Licenses"
  254. set _OSPP15VBS=
  255. for %%G in (
  256. "%ProgramFiles%"
  257. "%ProgramW6432%"
  258. "%ProgramFiles(x86)%"
  259. ) do if exist "%%~G\Microsoft Office\Office15\OSPP.VBS" (
  260. if not defined _OSPP15VBS set "_OSPP15VBS=%%~G\Microsoft Office\Office15\OSPP.VBS"
  261. )
  262. if "%_Product15Ids%"=="" (
  263. if %_Office16% EQU 0 (set "msg=Office 2013 C2R ProductIDs are not detected"&goto :%_fC2R%) else (goto :CheckC2R)
  264. )
  265. if not exist "%_Licenses15Path%\ProPlus*.xrm-ms" (
  266. if %_Office16% EQU 0 (set "msg=Office 2013 C2R Licenses files are not detected"&goto :%_fC2R%) else (goto :CheckC2R)
  267. )
  268. if %winbuild% LSS 9200 if "%_OSPP15VBS%"=="" (
  269. if %_Office16% EQU 0 (set "msg=Office 2013 C2R Licensing tool OSPP.vbs is not detected"&goto :%_fC2R%) else (goto :CheckC2R)
  270. )
  271. :CheckC2R
  272. set _OMSI=0
  273. if %_Office16% EQU 0 (
  274. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\EntityPicker.dll" set _OMSI=1
  275. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\16.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\EntityPicker.dll" set _OMSI=1
  276. )
  277. if %_Office15% EQU 0 (
  278. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\15.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\EntityPicker.dll" set _OMSI=1
  279. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\15.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\EntityPicker.dll" set _OMSI=1
  280. )
  281. if %winbuild% GEQ 9200 (
  282. set _spp=SoftwareLicensingProduct
  283. set _sps=SoftwareLicensingService
  284. set "_vbsi=%_SLMGR% /ilc "
  285. set "_vbsf=%_SLMGR% /ilc "
  286. ) else (
  287. set _spp=OfficeSoftwareProtectionProduct
  288. set _sps=OfficeSoftwareProtectionService
  289. set _vbsi="!_OSPP15VBS!" /inslic:
  290. set _vbsf="!_OSPPVBS!" /inslic:
  291. )
  292. set "_wmi="
  293. call :qrSingle %_sps% Version
  294. for /f "tokens=2 delims==" %%# in ('%_qr%') do set _wmi=%%#
  295. if "%_wmi%"=="" (
  296. set "msg=%_sps% WMI version is not detected"
  297. goto :%_fC2R%
  298. )
  299. echo.
  300. echo %_ln%
  301. echo Checking Office Licenses...
  302. echo %_ln%
  303. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND Description LIKE '%%%%KMSCLIENT%%%%'" LicenseFamily
  304. %_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _KMS=1) || (set _KMS=0)
  305. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND Description LIKE '%%%%TIMEBASED%%%%'" LicenseFamily
  306. %_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Time=1) || (set _Time=0)
  307. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND Description LIKE '%%%%Trial%%%%'" LicenseFamily
  308. %_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Time=1)
  309. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND Description LIKE '%%%%Grace%%%%'" LicenseFamily
  310. %_qr% %_Nul2% | findstr /I /C:"Office" %_Nul1% && (set _Grace=1) || (set _Grace=0)
  311. call :qrQuery %_spp% "ApplicationID='%_oApp%'" LicenseFamily
  312. %_qr% > "!_temp!\crvchk.txt" 2>&1
  313. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND LicenseFamily LIKE 'Office16O365%%%%'" LicenseFamily
  314. if %_Office16% EQU 1 find /i "Office16MondoVL_KMS_Client" "!_temp!\crvchk.txt" %_Nul1% && (
  315. %_qr% %_Nul2% | find /i "O365" %_Nul1% || (set _Grace=1)
  316. )
  317. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND LicenseFamily LIKE 'OfficeO365%%%%'" LicenseFamily
  318. if %_Office15% EQU 1 find /i "OfficeMondoVL_KMS_Client" "!_temp!\crvchk.txt" %_Nul1% && (
  319. %_qr% %_Nul2% | find /i "O365" %_Nul1% || (set _Grace=1)
  320. )
  321. if %_Time% EQU 0 if %_Grace% EQU 0 if %_KMS% EQU 1 (
  322. set "msg=No Conversion or Cleanup required"
  323. goto :%_fC2R%
  324. )
  325. call :subOffice
  326. if %vNextOverride% EQU 1 if %_Cnvrt% EQU 1 (
  327. set sub_o365=0
  328. set sub_proj=0
  329. set sub_vsio=0
  330. if %sub_next% EQU 1 (
  331. reg delete HKCU\SOFTWARE\Microsoft\Office\16.0\Common\Licensing /f %_Nul3%
  332. rmdir /s /q "!_Local!\Microsoft\Office\Licenses\" %_Nul3%
  333. rmdir /s /q "!ProgramData!\Microsoft\Office\Licenses\" %_Nul3%
  334. )
  335. set sub_next=0
  336. )
  337. set _Retail=0
  338. set "_ocq=ApplicationID='%_oApp%' AND LicenseStatus='1' AND PartialProductKey is not NULL"
  339. call :qrQuery %_spp% "%_ocq%" Description fix
  340. %_qr% %_Nul2% |findstr /V /R "^$" >"!_temp!\crvRetail.txt"
  341. find /i "RETAIL channel" "!_temp!\crvRetail.txt" %_Nul1% && set _Retail=1
  342. find /i "RETAIL(MAK) channel" "!_temp!\crvRetail.txt" %_Nul1% && set _Retail=1
  343. find /i "TIMEBASED_SUB channel" "!_temp!\crvRetail.txt" %_Nul1% && set _Retail=1
  344. set rancopp=0
  345. if %_Cnvrt% EQU 1 if %sub_next% EQU 0 if %_Retail% EQU 0 if %_OMSI% EQU 0 if %_pwsh% equ 1 (
  346. echo.
  347. echo %_ln%
  348. echo Cleaning Current Office Licenses...
  349. echo %_ln%
  350. set rancopp=1
  351. %_Nul3% %_psc% "$f=[IO.File]::ReadAllText('!_batp!') -split ':embdbin\:.*';iex ($f[1])"
  352. title %_title%
  353. )
  354. :R16V
  355. echo.
  356. echo %_ln%
  357. echo Checking installed Office Products...
  358. echo %_ln%
  359. echo.
  360. set _SubID=O365ProPlus,O365Business,O365SmallBusPrem,O365HomePrem,O365EduCloud
  361. set _O16O365=0
  362. set _C16Msg=0&set _C16Vol=0
  363. set _C15Msg=0&set _C15Vol=0
  364. call :qrQuery %_spp% "%_ocq%" LicenseFamily fix
  365. if %_Retail% EQU 1 %_qr% %_Nul2% |findstr /V /R "^$" >"!_temp!\crvRetail.txt"
  366. call :qrQuery %_spp% "ApplicationID='%_oApp%'" LicenseFamily fix
  367. %_qr% %_Nul2% |findstr /V /R "^$" >"!_temp!\crvVolume.txt" 2>&1
  368. if %_Office16% EQU 0 goto :R15V
  369. set _S24ID=ProPlus2024,Standard2024
  370. set _S21ID=ProPlus2021,Standard2021
  371. set _S19ID=ProPlus2019,Standard2019
  372. set _S16ID=Mondo,Standard
  373. set _P24ID=ProjectPro2024,ProjectStd2024
  374. set _P21ID=ProjectPro2021,ProjectStd2021
  375. set _P19ID=ProjectPro2019,ProjectStd2019
  376. set _P16ID=ProjectPro,ProjectStd
  377. set _I24ID=VisioPro2024,VisioStd2024
  378. set _I21ID=VisioPro2021,VisioStd2021
  379. set _I19ID=VisioPro2019,VisioStd2019
  380. set _I16ID=VisioPro,VisioStd
  381. set _A24ID=Excel2024,Outlook2024,PowerPoint2024,Word2024
  382. set _A21ID=Excel2021,Outlook2021,PowerPoint2021,Publisher2021,Word2021
  383. set _A19ID=Excel2019,Outlook2019,PowerPoint2019,Publisher2019,Word2019
  384. set _A16ID=Excel,Outlook,PowerPoint,Publisher,Word
  385. set _E24ID=Access2024,SkypeforBusiness2024
  386. set _E21ID=Access2021,SkypeforBusiness2021
  387. set _E19ID=Access2019,SkypeforBusiness2019
  388. set _E16ID=Access,SkypeforBusiness
  389. set _R24ID=Professional2024,HomeBusiness2024,HomeStudent2024,Home2024
  390. set _R21ID=Professional2021,HomeBusiness2021,HomeStudent2021
  391. set _R19ID=Professional2019,HomeBusiness2019,HomeStudent2019
  392. set _R16ID=Professional,HomeBusiness,HomeStudent,%_SubID%
  393. set _V24ID=%_S24ID%,%_A24ID%,%_E24ID%,%_P24ID%,%_I24ID%
  394. set _V21ID=%_S21ID%,%_A21ID%,%_E21ID%,%_P21ID%,%_I21ID%
  395. set _V19ID=%_S19ID%,%_A19ID%,%_E19ID%,%_P19ID%,%_I19ID%
  396. set _V16ID=%_S16ID%,%_A16ID%,%_E16ID%,%_P16ID%,%_I16ID%
  397. set _RetID=%_R24ID%,%_V24ID%,%_R21ID%,%_V21ID%,%_R19ID%,%_V19ID%,%_R16ID%,%_V16ID%
  398. set _Suites=ProPlus,%_S16ID%,%_R16ID%,%_S19ID%,%_R19ID%,%_S21ID%,%_R21ID%,%_S24ID%,%_R24ID%
  399. set _PrjSKU=%_P16ID%,%_P19ID%,%_P21ID%,%_P24ID%
  400. set _VisSKU=%_I16ID%,%_I19ID%,%_I21ID%,%_I24ID%
  401. echo %_ProductIds%>"!_temp!\crvProductIds.txt"
  402. for %%a in (%_RetID%,ProPlus,OneNote,Publisher2024,Home,Home2019,Home2021) do (
  403. set _%%a=0
  404. )
  405. for %%a in (%_RetID%,OneNote) do (
  406. findstr /I /C:"%%aRetail" "!_temp!\crvProductIds.txt" %_Nul1% && set _%%a=1
  407. )
  408. if !_LTS24! EQU 0 for %%a in (%_V24ID%) do (
  409. set _%%a=0
  410. )
  411. if !_LTS24! EQU 1 for %%a in (%_V24ID%) do (
  412. findstr /I /C:"%%aVolume" "!_temp!\crvProductIds.txt" %_Nul1% && (
  413. find /i "Office24%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C16Vol=1) || (set _%%a=1)
  414. )
  415. )
  416. if !_LTS21! EQU 0 for %%a in (%_V21ID%) do (
  417. set _%%a=0
  418. )
  419. if !_LTS21! EQU 1 for %%a in (%_V21ID%) do (
  420. findstr /I /C:"%%aVolume" "!_temp!\crvProductIds.txt" %_Nul1% && (
  421. find /i "Office21%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C16Vol=1) || (set _%%a=1)
  422. )
  423. )
  424. if !_LTS19! EQU 0 for %%a in (%_V19ID%) do (
  425. set _%%a=0
  426. )
  427. if !_LTS19! EQU 1 for %%a in (%_V19ID%) do (
  428. findstr /I /C:"%%aVolume" "!_temp!\crvProductIds.txt" %_Nul1% && (
  429. find /i "Office19%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C16Vol=1) || (set _%%a=1)
  430. )
  431. )
  432. for %%a in (%_V16ID%,OneNote) do (
  433. findstr /I /C:"%%aVolume" "!_temp!\crvProductIds.txt" %_Nul1% && (
  434. find /i "Office16%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C16Vol=1) || (set _%%a=1)
  435. )
  436. )
  437. reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && (
  438. find /i "Office16ProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C16Vol=1) || (set _ProPlus=1)
  439. )
  440. reg query %_PRIDs%\ProPlusVolume.16 %_Nul3% && (
  441. find /i "Office16ProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C16Vol=1) || (set _ProPlus=1)
  442. )
  443. if %_Retail% EQU 1 for %%a in (%_RetID%,OneNote) do (
  444. findstr /I /C:"%%aRetail" "!_temp!\crvProductIds.txt" %_Nul1% && (
  445. find /i "Office16%%aR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  446. find /i "Office16%%aR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  447. find /i "Office16%%aR_Sub" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  448. find /i "Office16%%aR_PIN" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  449. find /i "Office16%%aE5R_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  450. find /i "Office16%%aEDUR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  451. find /i "Office16%%aMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  452. find /i "Office16%%aO365R_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  453. find /i "Office16%%aCO365R_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  454. find /i "Office16%%aVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  455. find /i "Office16%%aXC2RVL_MAKC2R" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  456. find /i "Office19%%aR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  457. find /i "Office19%%aR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  458. find /i "Office19%%aMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  459. find /i "Office19%%aVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  460. find /i "Office21%%aR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  461. find /i "Office21%%aR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  462. find /i "Office21%%aMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  463. find /i "Office21%%aVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  464. find /i "Office24%%aR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  465. find /i "Office24%%aR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  466. find /i "Office24%%aMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  467. find /i "Office24%%aVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  468. )
  469. )
  470. if %_Retail% EQU 1 reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && (
  471. find /i "Office16ProPlusR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  472. find /i "Office16ProPlusR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  473. find /i "Office16ProPlusMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  474. find /i "Office16ProPlusVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  475. )
  476. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND LicenseFamily like 'Office16O365%%%%'" LicenseFamily
  477. find /i "Office16MondoVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (
  478. %_qr% %_Nul2% | find /i "O365" %_Nul1% && (
  479. for %%a in (%_SubID%) do set _%%a=0
  480. )
  481. )
  482. if %sub_o365% EQU 1 (
  483. for %%a in (%_Suites%) do set _%%a=0
  484. echo Microsoft Office is activated with a vNext license.
  485. echo.
  486. )
  487. if %sub_proj% EQU 1 (
  488. for %%a in (%_PrjSKU%) do set _%%a=0
  489. echo Microsoft Project is activated with a vNext license.
  490. echo.
  491. )
  492. if %sub_vsio% EQU 1 (
  493. for %%a in (%_VisSKU%) do set _%%a=0
  494. echo Microsoft Visio is activated with a vNext license.
  495. echo.
  496. )
  497. if %_Cnvrt% NEQ 1 (if %_Office15% EQU 1 (goto :R15V) else (set "msg=Finished"&goto :%_fC2R%))
  498. for %%a in (%_RetID%,ProPlus,OneNote) do if !_%%a! EQU 1 (
  499. set _C16Msg=1&set _C16Vol=1
  500. )
  501. if %_C16Msg% EQU 1 (
  502. echo.
  503. echo %_ln%
  504. echo Installing Office Volume Licenses...
  505. echo %_ln%
  506. echo.
  507. )
  508. if %_C16Msg% EQU 0 goto :endRV16
  509. set "_arr="
  510. for %%# in ("!_LicensesPath!\client-issuance-*.xrm-ms") do (
  511. if %WMI_PS% NEQ 0 (
  512. if defined _arr (set "_arr=!_arr!;"!_LicensesPath!\%%~nx#"") else (set "_arr="!_LicensesPath!\%%~nx#"")
  513. ) else (
  514. %_cscript% %_vbsf%"!_LicensesPath!\%%~nx#"
  515. )
  516. )
  517. if %WMI_PS% NEQ 0 (
  518. %_Nul3% %_psc% "$sls='%_sps%'; $f=[IO.File]::ReadAllText('!_batp!') -split ':embdxrm\:.*'; iex ($f[1]); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_LicensesPath!\pkeyconfig-office.xrm-ms"'"
  519. ) else (
  520. %_cscript% %_vbsf%"!_LicensesPath!\pkeyconfig-office.xrm-ms"
  521. )
  522. set _jump=0
  523. set _DidO365=0
  524. if !_Mondo! EQU 1 (
  525. call :InsLic Mondo
  526. )
  527. if !_O365ProPlus! EQU 1 (
  528. set _DidO365=1
  529. echo O365ProPlus 2016 Suite ^<-^> Mondo 2016 Licenses
  530. call :InsLic O365ProPlus DRNV7-VGMM2-B3G9T-4BF84-VMFTK
  531. if !_Mondo! EQU 0 call :InsLic Mondo
  532. )
  533. if !_O365Business! EQU 1 if !_DidO365! EQU 0 (
  534. set _DidO365=1
  535. echo O365Business 2016 Suite ^<-^> Mondo 2016 Licenses
  536. call :InsLic O365Business NCHRJ-3VPGW-X73DM-6B36K-3RQ6B
  537. if !_Mondo! EQU 0 call :InsLic Mondo
  538. )
  539. if !_O365SmallBusPrem! EQU 1 if !_DidO365! EQU 0 (
  540. set _DidO365=1
  541. echo O365SmallBusPrem 2016 Suite ^<-^> Mondo 2016 Licenses
  542. call :InsLic O365SmallBusPrem 3FBRX-NFP7C-6JWVK-F2YGK-H499R
  543. if !_Mondo! EQU 0 call :InsLic Mondo
  544. )
  545. if !_O365HomePrem! EQU 1 if !_DidO365! EQU 0 (
  546. set _DidO365=1
  547. echo O365HomePrem 2016 Suite ^<-^> Mondo 2016 Licenses
  548. call :InsLic O365HomePrem 9FNY8-PWWTY-8RY4F-GJMTV-KHGM9
  549. if !_Mondo! EQU 0 call :InsLic Mondo
  550. )
  551. if !_O365EduCloud! EQU 1 if !_DidO365! EQU 0 (
  552. set _DidO365=1
  553. echo O365EduCloud 2016 Suite ^<-^> Mondo 2016 Licenses
  554. call :InsLic O365EduCloud 8843N-BCXXD-Q84H8-R4Q37-T3CPT
  555. if !_Mondo! EQU 0 call :InsLic Mondo
  556. )
  557. if !_DidO365! EQU 1 set _jump=1&set _O16O365=1
  558. if !_Mondo! EQU 1 if !_DidO365! EQU 0 (
  559. echo Mondo 2016 Suite
  560. call :InsLic O365ProPlus DRNV7-VGMM2-B3G9T-4BF84-VMFTK
  561. goto :endRV16
  562. )
  563. for %%a in (%_P16ID%,%_I16ID%) do (
  564. if !_%%a2024! EQU 1 (echo %%a 2024 SKU&call :InsLic %%a2024)
  565. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (echo %%a 2021 SKU&call :InsLic %%a2021)
  566. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (echo %%a 2019 SKU -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  567. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (echo %%a 2016 SKU -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  568. )
  569. if !_jump! EQU 1 goto :endRV16
  570. for %%a in (ProPlus) do (
  571. if !_%%a2024! EQU 1 (set _jump=1&echo %%a 2024 Suite&call :InsLic ProPlus2024)
  572. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (set _jump=1&echo %%a 2021 Suite&call :InsLic ProPlus2021)
  573. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (set _jump=1&echo %%a 2019 Suite -^> ProPlus%_ons% Licenses&call :InsLic ProPlus%_tag%)
  574. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (set _jump=1&echo %%a 2016 Suite -^> ProPlus%_ons% Licenses&call :InsLic ProPlus%_tag%)
  575. )
  576. if !_jump! EQU 1 goto :endRV16
  577. for %%a in (Professional) do (
  578. if !_%%a2024! EQU 1 (set _jump=1&echo %%a 2024 Suite -^> ProPlus 2024 Licenses&call :InsLic ProPlus2024)
  579. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (set _jump=1&echo %%a 2021 Suite -^> ProPlus 2021 Licenses&call :InsLic ProPlus2021)
  580. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (set _jump=1&echo %%a 2019 Suite -^> ProPlus%_ons% Licenses&call :InsLic ProPlus%_tag%)
  581. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (set _jump=1&echo %%a 2016 Suite -^> ProPlus%_ons% Licenses&call :InsLic ProPlus%_tag%)
  582. )
  583. if !_jump! EQU 1 goto :endRV16
  584. for %%a in (SkypeforBusiness) do (
  585. if !_%%a2024! EQU 1 (echo %%a 2024 App&call :InsLic %%a2024)
  586. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (echo %%a 2021 App&call :InsLic %%a2021)
  587. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (echo %%a 2019 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  588. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (echo %%a 2016 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  589. )
  590. for %%a in (Access) do (
  591. if !_%%a2024! EQU 1 (echo %%a 2024 App&call :InsLic %%a2024)
  592. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (echo %%a 2021 App&call :InsLic %%a2021)
  593. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (echo %%a 2019 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  594. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (echo %%a 2016 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  595. )
  596. for %%a in (Standard) do (
  597. if !_%%a2024! EQU 1 (set _jump=1&echo %%a 2024 Suite&call :InsLic Standard2024)
  598. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (set _jump=1&echo %%a 2021 Suite&call :InsLic Standard2021)
  599. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (set _jump=1&echo %%a 2019 Suite -^> Standard%_ons% Licenses&call :InsLic Standard%_tag%)
  600. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (set _jump=1&echo %%a 2016 Suite -^> Standard%_ons% Licenses&call :InsLic Standard%_tag%)
  601. )
  602. if !_jump! EQU 1 goto :endRV16
  603. for %%a in (HomeBusiness,HomeStudent,Home) do (
  604. if !_%%a2024! EQU 1 (set _jump=1&echo %%a 2024 Suite -^> Standard 2024 Licenses&call :InsLic Standard2024)
  605. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (set _jump=1&echo %%a 2021 Suite -^> Standard 2021 Licenses&call :InsLic Standard2021)
  606. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (set _jump=1&echo %%a 2019 Suite -^> Standard%_ons% Licenses&call :InsLic Standard%_tag%)
  607. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (set _jump=1&echo %%a 2016 Suite -^> Standard%_ons% Licenses&call :InsLic Standard%_tag%)
  608. )
  609. if !_jump! EQU 1 goto :endRV16
  610. for %%a in (%_A16ID%) do (
  611. if !_%%a2024! EQU 1 (echo %%a 2024 App&call :InsLic %%a2024)
  612. if !_%%a2024! EQU 0 if !_%%a2021! EQU 1 (echo %%a 2021 App&call :InsLic %%a2021)
  613. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (echo %%a 2019 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  614. if !_%%a2024! EQU 0 if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (echo %%a 2016 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  615. )
  616. for %%a in (OneNote) do (
  617. if !_%%a! EQU 1 (echo %%a 2016 App&call :InsLic %%a)
  618. )
  619. :endRV16
  620. set _doPublisher=0
  621. if !_ProPlus2024! EQU 1 set _doPublisher=1
  622. if !_Professional2024! EQU 1 set _doPublisher=1
  623. if !_Standard2024! EQU 1 set _doPublisher=1
  624. if !_DidO365! EQU 1 set _doPublisher=0
  625. if !_doPublisher! EQU 1 for %%a in (Publisher) do (
  626. if !_%%a2021! EQU 1 (echo %%a 2021 App&call :InsLic %%a2021)
  627. if !_%%a2021! EQU 0 if !_%%a2019! EQU 1 (echo %%a 2019 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  628. if !_%%a2021! EQU 0 if !_%%a2019! EQU 0 if !_%%a! EQU 1 (echo %%a 2016 App -^> %%a%_ons% Licenses&call :InsLic %%a%_tag%)
  629. )
  630. if %_Office15% EQU 0 goto :GVLKC2R
  631. :R15V
  632. set _S15ID=Mondo,Standard
  633. set _P15ID=ProjectPro,ProjectStd
  634. set _I15ID=VisioPro,VisioStd
  635. set _A15ID=Excel,Groove,InfoPath,OneNote,Outlook,PowerPoint,Publisher,Word
  636. set _E15ID=Access,Lync
  637. set _V15ID=%_S15ID%,%_A15ID%,%_E15ID%,%_P15ID%,%_I15ID%
  638. set _R15ID=%_V15ID%,SPD,Professional,HomeBusiness,HomeStudent,%_SubID%
  639. echo %_Product15Ids%>"!_temp!\crvProduct15s.txt"
  640. for %%a in (%_R15ID%,ProPlus) do (
  641. set _%%a=0
  642. )
  643. for %%a in (%_R15ID%) do (
  644. findstr /I /C:"%%aRetail" "!_temp!\crvProduct15s.txt" %_Nul1% && set _%%a=1
  645. )
  646. for %%a in (%_V15ID%) do (
  647. findstr /I /C:"%%aVolume" "!_temp!\crvProduct15s.txt" %_Nul1% && (
  648. find /i "Office%%aVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _%%a=0&set _C15Vol=1) || (set _%%a=1)
  649. )
  650. )
  651. reg query %_PR15IDs%\Active\ProPlusRetail\x-none %_Nul3% && (
  652. find /i "OfficeProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C15Vol=1) || (set _ProPlus=1)
  653. )
  654. reg query %_PR15IDs%\Active\ProPlusVolume\x-none %_Nul3% && (
  655. find /i "OfficeProPlusVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (set _ProPlus=0&set _C15Vol=1) || (set _ProPlus=1)
  656. )
  657. if %_Retail% EQU 1 for %%a in (%_R15ID%) do (
  658. findstr /I /C:"%%aRetail" "!_temp!\crvProduct15s.txt" %_Nul1% && (
  659. find /i "Office%%aR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  660. find /i "Office%%aR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  661. find /i "Office%%aR_Sub" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  662. find /i "Office%%aR_PIN" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  663. find /i "Office%%aMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  664. find /i "Office%%aO365R_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  665. find /i "Office%%aCO365R_" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  666. find /i "Office%%aVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && (set _%%a=0)
  667. )
  668. )
  669. if %_Retail% EQU 1 reg query %_PR15IDs%\Active\ProPlusRetail\x-none %_Nul3% && (
  670. find /i "OfficeProPlusR_Retail" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  671. find /i "OfficeProPlusR_OEM" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  672. find /i "OfficeProPlusMSDNR_" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  673. find /i "OfficeProPlusVL_MAK" "!_temp!\crvRetail.txt" %_Nul1% && (set _ProPlus=0)
  674. )
  675. call :qrQuery %_spp% "ApplicationID='%_oApp%' AND LicenseFamily like 'OfficeO365%%%%'" LicenseFamily
  676. find /i "OfficeMondoVL_KMS_Client" "!_temp!\crvVolume.txt" %_Nul1% && (
  677. %_qr% %_Nul2% | find /i "O365" %_Nul1% && (
  678. for %%a in (%_SubID%) do set _%%a=0
  679. )
  680. )
  681. if %_Cnvrt% NEQ 1 (set "msg=Finished"&goto :%_fC2R%)
  682. for %%a in (%_R15ID%,ProPlus) do if !_%%a! EQU 1 (
  683. set _C15Msg=1&set _C15Vol=1
  684. )
  685. if %_C15Msg% EQU 1 if %_C16Msg% EQU 0 (
  686. echo.
  687. echo %_ln%
  688. echo Installing Office Volume Licenses...
  689. echo %_ln%
  690. echo.
  691. )
  692. if %_C15Msg% EQU 0 goto :endRV15
  693. set "_arr="
  694. for %%# in ("!_Licenses15Path!\client-issuance-*.xrm-ms") do (
  695. if %WMI_PS% NEQ 0 (
  696. if defined _arr (set "_arr=!_arr!;"!_Licenses15Path!\%%~nx#"") else (set "_arr="!_Licenses15Path!\%%~nx#"")
  697. ) else (
  698. %_cscript% %_vbsi%"!_Licenses15Path!\%%~nx#"
  699. )
  700. )
  701. if %WMI_PS% NEQ 0 (
  702. %_Nul3% %_psc% "$sls='%_sps%'; $f=[IO.File]::ReadAllText('!_batp!') -split ':embdxrm\:.*'; iex ($f[1]); InstallLicenseArr '!_arr!'; InstallLicenseFile '"!_Licenses15Path!\pkeyconfig-office.xrm-ms"'"
  703. ) else (
  704. %_cscript% %_vbsi%"!_Licenses15Path!\pkeyconfig-office.xrm-ms"
  705. )
  706. set _jump=0
  707. set _DidO365=0
  708. if !_Mondo! EQU 1 (
  709. call :Ins15Lic Mondo
  710. )
  711. if !_O365ProPlus! EQU 1 if !_O16O365! EQU 0 (
  712. set _DidO365=1
  713. echo O365ProPlus 2013 Suite ^<-^> Mondo 2013 Licenses
  714. call :Ins15Lic O365ProPlus DRNV7-VGMM2-B3G9T-4BF84-VMFTK
  715. if !_Mondo! EQU 0 call :Ins15Lic Mondo
  716. )
  717. if !_O365SmallBusPrem! EQU 1 if !_O16O365! EQU 0 if !_DidO365! EQU 0 (
  718. set _DidO365=1
  719. echo O365SmallBusPrem 2013 Suite ^<-^> Mondo 2013 Licenses
  720. call :Ins15Lic O365SmallBusPrem 3FBRX-NFP7C-6JWVK-F2YGK-H499R
  721. if !_Mondo! EQU 0 call :Ins15Lic Mondo
  722. )
  723. if !_O365HomePrem! EQU 1 if !_O16O365! EQU 0 if !_DidO365! EQU 0 (
  724. set _DidO365=1
  725. echo O365HomePrem 2013 Suite ^<-^> Mondo 2013 Licenses
  726. call :Ins15Lic O365HomePrem 9FNY8-PWWTY-8RY4F-GJMTV-KHGM9
  727. if !_Mondo! EQU 0 call :Ins15Lic Mondo
  728. )
  729. if !_O365Business! EQU 1 if !_O16O365! EQU 0 if !_DidO365! EQU 0 (
  730. set _DidO365=1
  731. echo O365Business 2013 Suite ^<-^> Mondo 2013 Licenses
  732. call :Ins15Lic O365Business MCPBN-CPY7X-3PK9R-P6GTT-H8P8Y
  733. if !_Mondo! EQU 0 call :Ins15Lic Mondo
  734. )
  735. if !_DidO365! EQU 1 set _jump=1
  736. if !_Mondo! EQU 1 if !_O16O365! EQU 0 if !_DidO365! EQU 0 (
  737. echo Mondo 2013 Suite
  738. call :Ins15Lic O365ProPlus DRNV7-VGMM2-B3G9T-4BF84-VMFTK
  739. goto :endRV15
  740. )
  741. for %%a in (%_P15ID%,%_I15ID%) do (
  742. if !_%%a! EQU 1 (echo %%a 2013 SKU&call :Ins15Lic %%a)
  743. )
  744. if !_Mondo! EQU 0 if !_DidO365! EQU 0 for %%a in (SPD) do (
  745. if !_%%a! EQU 1 (set _jump=1&echo SharePoint Designer 2013 App -^> Mondo 2013 Licenses&call :Ins15Lic Mondo)
  746. )
  747. if !_jump! EQU 1 goto :endRV15
  748. for %%a in (ProPlus) do (
  749. if !_%%a! EQU 1 (set _jump=1&echo %%a 2013 Suite&call :Ins15Lic %%a)
  750. )
  751. if !_jump! EQU 1 goto :endRV15
  752. for %%a in (Professional) do (
  753. if !_%%a! EQU 1 (set _jump=1&echo %%a 2013 Suite -^> ProPlus 2013 Licenses&call :Ins15Lic ProPlus)
  754. )
  755. if !_jump! EQU 1 goto :endRV15
  756. for %%a in (Lync) do (
  757. if !_%%a! EQU 1 (echo SkypeforBusiness 2015 App&call :Ins15Lic %%a)
  758. )
  759. for %%a in (Access) do (
  760. if !_%%a! EQU 1 (echo %%a 2013 App&call :Ins15Lic %%a)
  761. )
  762. for %%a in (Standard) do (
  763. if !_%%a! EQU 1 (set _jump=1&echo %%a 2013 Suite&call :Ins15Lic %%a)
  764. )
  765. if !_jump! EQU 1 goto :endRV15
  766. for %%a in (HomeBusiness,HomeStudent) do (
  767. if !_%%a! EQU 1 (set _jump=1&echo %%a 2013 Suite -^> Standard 2013 Licenses&call :Ins15Lic Standard)
  768. )
  769. if !_jump! EQU 1 goto :endRV15
  770. for %%a in (%_A15ID%) do (
  771. if !_%%a! EQU 1 (echo %%a 2013 App&call :Ins15Lic %%a)
  772. )
  773. :endRV15
  774. goto :GVLKC2R
  775. :InsLic
  776. set "_ID=%1Volume"
  777. set "_patt=%1VL_"
  778. set "_pkey="
  779. set "_kpey="
  780. if not "%2"=="" (
  781. set "_ID=%1Retail"
  782. set "_patt=%1R_"
  783. set "_pkey=PidKey=%2"
  784. set "_kpey=%2"
  785. )
  786. reg delete %_Config% /f /v %_ID%.OSPPReady %_Nul3%
  787. "!_Integrator!" /I /License PRIDName=%_ID%.16 %_pkey% PackageGUID="%_GUID%" PackageRoot="!_InstallRoot!" %_Nul1%
  788. set fallback=0
  789. call :qrQuery %_spp% "ApplicationID='%_oApp%'" LicenseFamily fix
  790. %_qr% %_Nul2% | find /i "%_patt%" %_Nul1% || (set fallback=1)
  791. if %fallback% equ 0 goto :IntOK
  792. set "_lsfs="
  793. for %%# in ("!_LicensesPath!\%_patt%*.xrm-ms") do (
  794. set "_lsfs=!_lsfs! %%~nx#"
  795. )
  796. if defined _kpey (
  797. for %%# in ("!_LicensesPath!\%1DemoR*.xrm-ms") do (
  798. set "_lsfs=!_lsfs! %%~nx#"
  799. )
  800. for %%# in ("!_LicensesPath!\%1E5R*.xrm-ms") do (
  801. set "_lsfs=!_lsfs! %%~nx#"
  802. )
  803. for %%# in ("!_LicensesPath!\%1EDUR*.xrm-ms") do (
  804. set "_lsfs=!_lsfs! %%~nx#"
  805. )
  806. for %%# in ("!_LicensesPath!\%1MSDNR*.xrm-ms") do (
  807. set "_lsfs=!_lsfs! %%~nx#"
  808. )
  809. for %%# in ("!_LicensesPath!\%1O365R*.xrm-ms") do (
  810. set "_lsfs=!_lsfs! %%~nx#"
  811. )
  812. for %%# in ("!_LicensesPath!\%1CO365R*.xrm-ms") do (
  813. set "_lsfs=!_lsfs! %%~nx#"
  814. )
  815. )
  816. set "_arr="
  817. for %%# in (!_lsfs!) do (
  818. if %WMI_PS% NEQ 0 (
  819. if defined _arr (set "_arr=!_arr!;"!_LicensesPath!\%%~nx#"") else (set "_arr="!_LicensesPath!\%%~nx#"")
  820. ) else (
  821. %_cscript% %_vbsf%"!_LicensesPath!\%%~nx#"
  822. )
  823. )
  824. if %WMI_PS% NEQ 0 (
  825. %_Nul3% %_psc% "$sls='%_sps%'; $f=[IO.File]::ReadAllText('!_batp!') -split ':embdxrm\:.*'; iex ($f[1]); InstallLicenseArr '!_arr!'"
  826. )
  827. call :qrPKey %_sps% %_wmi% %_kpey%
  828. if defined _kpey %_qr% %_Nul3%
  829. :IntOK
  830. reg add %_Config% /f /v %_ID%.OSPPReady /t REG_SZ /d 1 %_Nul1%
  831. reg query %_Config% /v ProductReleaseIds | findstr /I "%_ID%" %_Nul1%
  832. if %errorlevel% NEQ 0 (
  833. for /f "skip=2 tokens=2*" %%a in ('reg query %_Config% /v ProductReleaseIds') do reg add %_Config% /v ProductReleaseIds /t REG_SZ /d "%%b,%_ID%" /f %_Nul1%
  834. )
  835. exit /b
  836. :Ins15Lic
  837. set "_ID=%1Volume"
  838. set "_patt=%1VL_"
  839. set "_pkey="
  840. if not "%2"=="" (
  841. set "_ID=%1Retail"
  842. set "_patt=%1R_"
  843. set "_pkey=%2"
  844. )
  845. reg delete %_OSPP15Ready% /f /v %_ID%.OSPPReady %_Nul3%
  846. set "_arr="
  847. for %%# in ("!_Licenses15Path!\%_patt%*.xrm-ms") do (
  848. if %WMI_PS% NEQ 0 (
  849. if defined _arr (set "_arr=!_arr!;"!_Licenses15Path!\%%~nx#"") else (set "_arr="!_Licenses15Path!\%%~nx#"")
  850. ) else (
  851. %_cscript% %_vbsi%"!_Licenses15Path!\%%~nx#"
  852. )
  853. )
  854. if %WMI_PS% NEQ 0 (
  855. %_Nul3% %_psc% "$sls='%_sps%'; $f=[IO.File]::ReadAllText('!_batp!') -split ':embdxrm\:.*'; iex ($f[1]); InstallLicenseArr '!_arr!'"
  856. )
  857. call :qrPKey %_sps% %_wmi% %_pkey%
  858. if defined _pkey %_qr% %_Nul3%
  859. reg add %_OSPP15Ready% /f /v %_ID%.OSPPReady /t %_OSPP15ReadT% /d 1 %_Nul1%
  860. reg query %_Con15fig% %_Nul2% | findstr /I "%_ID%" %_Nul1%
  861. if %errorlevel% NEQ 0 (
  862. for /f "skip=2 tokens=2*" %%a in ('reg query %_Con15fig% %_Nul6%') do reg add %_Con15fig% /t REG_SZ /d "%%b,%_ID%" /f %_Nul1%
  863. )
  864. exit /b
  865. :GVLKC2R
  866. set _CtRMsg=0
  867. if %_C16Msg% EQU 1 set _CtRMsg=1
  868. if %_C15Msg% EQU 1 set _CtRMsg=1
  869. if %_CtRMsg% EQU 1 (
  870. echo %_ln%
  871. echo Installing Missing KMS Client Keys...
  872. echo %_ln%
  873. echo.
  874. )
  875. call :qrMethod %_sps% Version %_wmi% RefreshLicenseStatus
  876. if %winbuild% GEQ 9200 %_qr% %_Nul3%
  877. for %%# in (15,16,19,21,24) do call :C2RLoc %%#
  878. if %_Retail% EQU 0 (
  879. for %%# in (15) do if !_Loc%%#! EQU 0 call :C2Runi %%#
  880. )
  881. if %_Retail% EQU 0 if %sub_o365% EQU 0 if %sub_proj% EQU 0 if %sub_vsio% EQU 0 (
  882. for %%# in (16,19,21,24) do if !_Loc%%#! EQU 0 call :C2Runi %%#
  883. )
  884. if %_C15Vol% EQU 1 (
  885. for %%# in (15) do if !_Loc%%#! EQU 1 call :C2Rins %%#
  886. )
  887. if %_C16Vol% EQU 1 (
  888. for %%# in (16,19,21,24) do if !_Loc%%#! EQU 1 call :C2Rins %%#
  889. )
  890. call :qrMethod %_sps% Version %_wmi% RefreshLicenseStatus
  891. if %winbuild% GEQ 9200 %_qr% %_Nul3%
  892. if exist "%SysPath%\spp\store_test\2.0\tokens.dat" (
  893. echo.
  894. echo %_ln%
  895. echo Refreshing Windows Insider Preview Licenses...
  896. echo %_ln%
  897. echo.
  898. if %WMI_PS% NEQ 0 (
  899. %_Nul3% %_psc% "$sls='%_sps%'; $f=[IO.File]::ReadAllText('!_batp!') -split ':embdxrm\:.*'; iex ($f[1]); ReinstallLicenses"
  900. if !ERRORLEVEL! NEQ 0 %_Nul3% %_psc% "$sls='%_sps%'; $f=[IO.File]::ReadAllText('!_batp!') -split ':embdxrm\:.*'; iex ($f[1]); ReinstallLicenses"
  901. ) else (
  902. %_cscript% %_SLMGR% /rilc
  903. if !ERRORLEVEL! NEQ 0 %_cscript% %_SLMGR% /rilc
  904. )
  905. )
  906. set "msg=Finished"&goto :%_fC2R%
  907. :C2Runi
  908. call :qrQuery %_spp% "Name LIKE 'Office %~1%%%%' AND PartialProductKey is not NULL" ID
  909. for /f "tokens=2 delims==" %%# in ('%_qr% %_Nul6%') do (set "aID=%%#"&call :UniKey)
  910. exit /b
  911. :C2Rins
  912. call :qrQuery %_spp% "Description LIKE 'Office %1, VOLUME_KMSCLIENT%%%%' AND PartialProductKey is NULL" ID
  913. for /f "tokens=2 delims==" %%# in ('%_qr% %_Nul6%') do (set "aID=%%#"&call :InsKey)
  914. exit /b
  915. :C2RLoc
  916. set _Loc%1=0
  917. if %1 EQU 19 (
  918. if defined _ProductIds reg query %_Config% /v ProductReleaseIds %_Nul2% | findstr 2019 %_Nul1% && set _Loc%1=1
  919. exit /b
  920. )
  921. if %1 EQU 21 (
  922. if defined _ProductIds reg query %_Config% /v ProductReleaseIds %_Nul2% | findstr 2021 %_Nul1% && set _Loc%1=1
  923. exit /b
  924. )
  925. if %1 EQU 24 (
  926. if defined _ProductIds reg query %_Config% /v ProductReleaseIds %_Nul2% | findstr 2024 %_Nul1% && set _Loc%1=1
  927. exit /b
  928. )
  929. for /f "skip=2 tokens=2*" %%a in ('"reg query %_onat%\%1.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\EntityPicker.dll" (
  930. set _Loc%1=1
  931. )
  932. for /f "skip=2 tokens=2*" %%a in ('"reg query %_owow%\%1.0\Common\InstallRoot /v Path" %_Nul6%') do if exist "%%b\EntityPicker.dll" (
  933. set _Loc%1=1
  934. )
  935. if %1 EQU 16 if defined _ProductIds (
  936. for /f "skip=2 tokens=2*" %%a in ('reg query %_Config% /v ProductReleaseIds') do echo %%b>"!_temp!\crvO16.txt"
  937. for %%a in (%_V16ID%,ProjectProX,ProjectStdX,VisioProX,VisioStdX) do (
  938. findstr /I /C:"%%aVolume" "!_temp!\crvO16.txt" %_Nul1% && set _Loc%1=1
  939. )
  940. for %%a in (%_V16ID%,%_R16ID%) do (
  941. findstr /I /C:"%%aRetail" "!_temp!\crvO16.txt" %_Nul1% && set _Loc%1=1
  942. )
  943. reg query %_PRIDs%\ProPlusRetail.16 %_Nul3% && set _Loc%1=1
  944. reg query %_PRIDs%\ProPlusVolume.16 %_Nul3% && set _Loc%1=1
  945. exit /b
  946. )
  947. if %1 EQU 15 if defined _Product15Ids (
  948. set _Loc%1=1
  949. exit /b
  950. )
  951. if exist "%ProgramFiles%\Microsoft Office\Office%1\OSPP.VBS" set _Loc%1=1
  952. if not %xOS%==x86 if exist "%ProgramW6432%\Microsoft Office\Office%1\OSPP.VBS" set _Loc%1=1
  953. if not %xOS%==x86 if exist "%ProgramFiles(x86)%\Microsoft Office\Office%1\OSPP.VBS" set _Loc%1=1
  954. exit /b
  955. :subOffice
  956. set kNext=HKCU\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext
  957. set sub_next=0
  958. set sub_o365=0
  959. set sub_proj=0
  960. set sub_vsio=0
  961. set _Identity=0
  962. dir /b /s /a:-d "!_Local!\Microsoft\Office\Licenses\*" %_Nul3% && (set _Identity=1&set sub_next=1)
  963. dir /b /s /a:-d "!ProgramData!\Microsoft\Office\Licenses\*" %_Nul3% && (set _Identity=1&set sub_next=1)
  964. if %_Identity% EQU 0 call :officeSub
  965. exit /b
  966. :officeSub
  967. reg query %kNext% %_Nul3% || exit /b
  968. reg query %kNext% | findstr /i /r ".*retail" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x2" %_Nul1% && (set sub_o365=1)
  969. reg query %kNext% | findstr /i /r ".*retail" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x3" %_Nul1% && (set sub_o365=1)
  970. reg query %kNext% | findstr /i /r ".*volume" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x2" %_Nul1% && (set sub_o365=1)
  971. reg query %kNext% | findstr /i /r ".*volume" %_Nul2% | findstr /i /v "project visio" %_Nul2% | find /i "0x3" %_Nul1% && (set sub_o365=1)
  972. reg query %kNext% | findstr /i /r "project.*" %_Nul2% | find /i "0x2" %_Nul1% && set sub_proj=1
  973. reg query %kNext% | findstr /i /r "project.*" %_Nul2% | find /i "0x3" %_Nul1% && set sub_proj=1
  974. reg query %kNext% | findstr /i /r "visio.*" %_Nul2% | find /i "0x2" %_Nul1% && set sub_vsio=1
  975. reg query %kNext% | findstr /i /r "visio.*" %_Nul2% | find /i "0x3" %_Nul1% && set sub_vsio=1
  976. if %sub_o365% EQU 1 set sub_next=1
  977. if %sub_proj% EQU 1 set sub_next=1
  978. if %sub_vsio% EQU 1 set sub_next=1
  979. exit /b
  980. :UniKey
  981. call :qrMethod %_spp% ID %aID% UninstallProductKey
  982. %_qr% %_Nul3%
  983. exit /b
  984. :InsKey
  985. set _eof=0
  986. for %%A in (
  987. fceda083-1203-402a-8ec4-3d7ed9f3648c,aaea0dc8-78e1-4343-9f25-b69b83dd1bce,4ab4d849-aabc-43fb-87ee-3aed02518891
  988. f3fb2d68-83dd-4c8b-8f09-08e0d950ac3b,76093b1b-7057-49d7-b970-638ebcbfd873,a3b44174-2451-4cd6-b25f-66638bfb9046
  989. 0bc88885-718c-491d-921f-6f214349e79c,fc7c4d0c-2e85-4bb9-afd4-01ed1476b5e9,500f6619-ef93-4b75-bcb4-82819998a3ca
  990. e914ea6e-a5fa-4439-a394-a9bb3293ca09
  991. 1dc00701-03af-4680-b2af-007ffc758a1f
  992. ) do (
  993. if /i "%aID%" EQU "%%A" set _eof=1
  994. )
  995. if %_eof% EQU 1 exit /b
  996. set "_key="
  997. call :qrQuery %_spp% "ID='%aID%'" LicenseFamily
  998. for /f "tokens=2 delims==" %%# in ('%_qr%') do echo %%#
  999. call :keys %aID%
  1000. if "%_key%"=="" (echo No associated KMS Client key found&echo.&exit /b)
  1001. call :qrPKey %_sps% %_wmi% %_key%
  1002. %_qr% %_Nul3%
  1003. set ERRORCODE=%ERRORLEVEL%
  1004. if %ERRORCODE% NEQ 0 (
  1005. cmd /c exit /b %ERRORCODE%
  1006. echo Failed: 0x!=ExitCode!
  1007. )
  1008. echo.
  1009. exit /b
  1010. :keys
  1011. if "%~1"=="" exit /b
  1012. goto :%1 %_Nul2%
  1013. :: Office 2024
  1014. :8d368fc1-9470-4be2-8d66-90e836cbb051
  1015. set "_key=XJ2XN-FW8RK-P4HMP-DKDBV-GCVGB" &:: Professional Plus
  1016. exit /b
  1017. :bbac904f-6a7e-418a-bb4b-24c85da06187
  1018. set "_key=V28N4-JG22K-W66P8-VTMGK-H6HGR" &:: Standard
  1019. exit /b
  1020. :f510af75-8ab7-4426-a236-1bfb95c34ff8
  1021. set "_key=FQQ23-N4YCY-73HQ3-FM9WC-76HF4" &:: Project Professional
  1022. exit /b
  1023. :9f144f27-2ac5-40b9-899d-898c2b8b4f81
  1024. set "_key=PD3TT-NTHQQ-VC7CY-MFXK3-G87F8" &:: Project Standard
  1025. exit /b
  1026. :fa187091-8246-47b1-964f-80a0b1e5d69a
  1027. set "_key=B7TN8-FJ8V3-7QYCP-HQPMV-YY89G" &:: Visio Professional
  1028. exit /b
  1029. :923fa470-aa71-4b8b-b35c-36b79bf9f44b
  1030. set "_key=JMMVY-XFNQC-KK4HK-9H7R3-WQQTV" &:: Visio Standard
  1031. exit /b
  1032. :72e9faa7-ead1-4f3d-9f6e-3abc090a81d7
  1033. set "_key=82FTR-NCHR7-W3944-MGRHM-JMCWD" &:: Access
  1034. exit /b
  1035. :cbbba2c3-0ff5-4558-846a-043ef9d78559
  1036. set "_key=F4DYN-89BP2-WQTWJ-GR8YC-CKGJG" &:: Excel
  1037. exit /b
  1038. :bef3152a-8a04-40f2-a065-340c3f23516d
  1039. set "_key=D2F8D-N3Q3B-J28PV-X27HD-RJWB9" &:: Outlook
  1040. exit /b
  1041. :b63626a4-5f05-4ced-9639-31ba730a127e
  1042. set "_key=CW94N-K6GJH-9CTXY-MG2VC-FYCWP" &:: PowerPoint
  1043. exit /b
  1044. :0002290a-2091-4324-9e53-3cfe28884cde
  1045. set "_key=4NKHF-9HBQF-Q3B6C-7YV34-F64P3" &:: Skype for Business
  1046. exit /b
  1047. :d0eded01-0881-4b37-9738-190400095098
  1048. set "_key=MQ84N-7VYDM-FXV7C-6K7CC-VFW9J" &:: Word
  1049. exit /b
  1050. :: Office 2021
  1051. :fbdb3e18-a8ef-4fb3-9183-dffd60bd0984
  1052. set "_key=FXYTK-NJJ8C-GB6DW-3DYQT-6F7TH" &:: Professional Plus
  1053. exit /b
  1054. :080a45c5-9f9f-49eb-b4b0-c3c610a5ebd3
  1055. set "_key=KDX7X-BNVR8-TXXGX-4Q7Y8-78VT3" &:: Standard
  1056. exit /b
  1057. :76881159-155c-43e0-9db7-2d70a9a3a4ca
  1058. set "_key=FTNWT-C6WBT-8HMGF-K9PRX-QV9H8" &:: Project Professional
  1059. exit /b
  1060. :6dd72704-f752-4b71-94c7-11cec6bfc355
  1061. set "_key=J2JDC-NJCYY-9RGQ4-YXWMH-T3D4T" &:: Project Standard
  1062. exit /b
  1063. :fb61ac9a-1688-45d2-8f6b-0674dbffa33c
  1064. set "_key=KNH8D-FGHT4-T8RK3-CTDYJ-K2HT4" &:: Visio Professional
  1065. exit /b
  1066. :72fce797-1884-48dd-a860-b2f6a5efd3ca
  1067. set "_key=MJVNY-BYWPY-CWV6J-2RKRT-4M8QG" &:: Visio Standard
  1068. exit /b
  1069. :1fe429d8-3fa7-4a39-b6f0-03dded42fe14
  1070. set "_key=WM8YG-YNGDD-4JHDC-PG3F4-FC4T4" &:: Access
  1071. exit /b
  1072. :ea71effc-69f1-4925-9991-2f5e319bbc24
  1073. set "_key=NWG3X-87C9K-TC7YY-BC2G7-G6RVC" &:: Excel
  1074. exit /b
  1075. :a5799e4c-f83c-4c6e-9516-dfe9b696150b
  1076. set "_key=C9FM6-3N72F-HFJXB-TM3V9-T86R9" &:: Outlook
  1077. exit /b
  1078. :6e166cc3-495d-438a-89e7-d7c9e6fd4dea
  1079. set "_key=TY7XF-NFRBR-KJ44C-G83KF-GX27K" &:: PowerPoint
  1080. exit /b
  1081. :aa66521f-2370-4ad8-a2bb-c095e3e4338f
  1082. set "_key=2MW9D-N4BXM-9VBPG-Q7W6M-KFBGQ" &:: Publisher
  1083. exit /b
  1084. :1f32a9af-1274-48bd-ba1e-1ab7508a23e8
  1085. set "_key=HWCXN-K3WBT-WJBKY-R8BD9-XK29P" &:: Skype for Business
  1086. exit /b
  1087. :abe28aea-625a-43b1-8e30-225eb8fbd9e5
  1088. set "_key=TN8H9-M34D3-Y64V9-TR72V-X79KV" &:: Word
  1089. exit /b
  1090. :: Office 2019
  1091. :85dd8b5f-eaa4-4af3-a628-cce9e77c9a03
  1092. set "_key=NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP" &:: Professional Plus
  1093. exit /b
  1094. :6912a74b-a5fb-401a-bfdb-2e3ab46f4b02
  1095. set "_key=6NWWJ-YQWMR-QKGCB-6TMB3-9D9HK" &:: Standard
  1096. exit /b
  1097. :2ca2bf3f-949e-446a-82c7-e25a15ec78c4
  1098. set "_key=B4NPR-3FKK7-T2MBV-FRQ4W-PKD2B" &:: Project Professional
  1099. exit /b
  1100. :1777f0e3-7392-4198-97ea-8ae4de6f6381
  1101. set "_key=C4F7P-NCP8C-6CQPT-MQHV9-JXD2M" &:: Project Standard
  1102. exit /b
  1103. :5b5cf08f-b81a-431d-b080-3450d8620565
  1104. set "_key=9BGNQ-K37YR-RQHF2-38RQ3-7VCBB" &:: Visio Professional
  1105. exit /b
  1106. :e06d7df3-aad0-419d-8dfb-0ac37e2bdf39
  1107. set "_key=7TQNQ-K3YQQ-3PFH7-CCPPM-X4VQ2" &:: Visio Standard
  1108. exit /b
  1109. :9e9bceeb-e736-4f26-88de-763f87dcc485
  1110. set "_key=9N9PT-27V4Y-VJ2PD-YXFMF-YTFQT" &:: Access
  1111. exit /b
  1112. :237854e9-79fc-4497-a0c1-a70969691c6b
  1113. set "_key=TMJWT-YYNMB-3BKTF-644FC-RVXBD" &:: Excel
  1114. exit /b
  1115. :c8f8a301-19f5-4132-96ce-2de9d4adbd33
  1116. set "_key=7HD7K-N4PVK-BHBCQ-YWQRW-XW4VK" &:: Outlook
  1117. exit /b
  1118. :3131fd61-5e4f-4308-8d6d-62be1987c92c
  1119. set "_key=RRNCX-C64HY-W2MM7-MCH9G-TJHMQ" &:: PowerPoint
  1120. exit /b
  1121. :9d3e4cca-e172-46f1-a2f4-1d2107051444
  1122. set "_key=G2KWX-3NW6P-PY93R-JXK2T-C9Y9V" &:: Publisher
  1123. exit /b
  1124. :734c6c6e-b0ba-4298-a891-671772b2bd1b
  1125. set "_key=NCJ33-JHBBY-HTK98-MYCV8-HMKHJ" &:: Skype for Business
  1126. exit /b
  1127. :059834fe-a8ea-4bff-b67b-4d006b5447d3
  1128. set "_key=PBX3G-NWMT6-Q7XBW-PYJGG-WXD33" &:: Word
  1129. exit /b
  1130. :: Office 2016
  1131. :829b8110-0e6f-4349-bca4-42803577788d
  1132. set "_key=WGT24-HCNMF-FQ7XH-6M8K7-DRTW9" &:: Project Professional C2R-P
  1133. exit /b
  1134. :cbbaca45-556a-4416-ad03-bda598eaa7c8
  1135. set "_key=D8NRQ-JTYM3-7J2DX-646CT-6836M" &:: Project Standard C2R-P
  1136. exit /b
  1137. :b234abe3-0857-4f9c-b05a-4dc314f85557
  1138. set "_key=69WXN-MBYV6-22PQG-3WGHK-RM6XC" &:: Visio Professional C2R-P
  1139. exit /b
  1140. :361fe620-64f4-41b5-ba77-84f8e079b1f7
  1141. set "_key=NY48V-PPYYH-3F4PX-XJRKJ-W4423" &:: Visio Standard C2R-P
  1142. exit /b
  1143. :e914ea6e-a5fa-4439-a394-a9bb3293ca09
  1144. set "_key=DMTCJ-KNRKX-26982-JYCKT-P7KB6" &:: MondoR
  1145. exit /b
  1146. :9caabccb-61b1-4b4b-8bec-d10a3c3ac2ce
  1147. set "_key=HFTND-W9MK4-8B7MJ-B6C4G-XQBR2" &:: Mondo
  1148. exit /b
  1149. :d450596f-894d-49e0-966a-fd39ed4c4c64
  1150. set "_key=XQNVK-8JYDB-WJ9W3-YJ8YR-WFG99" &:: Professional Plus
  1151. exit /b
  1152. :dedfa23d-6ed1-45a6-85dc-63cae0546de6
  1153. set "_key=JNRGM-WHDWX-FJJG3-K47QV-DRTFM" &:: Standard
  1154. exit /b
  1155. :4f414197-0fc2-4c01-b68a-86cbb9ac254c
  1156. set "_key=YG9NW-3K39V-2T3HJ-93F3Q-G83KT" &:: Project Professional
  1157. exit /b
  1158. :da7ddabc-3fbe-4447-9e01-6ab7440b4cd4
  1159. set "_key=GNFHQ-F6YQM-KQDGJ-327XX-KQBVC" &:: Project Standard
  1160. exit /b
  1161. :6bf301c1-b94a-43e9-ba31-d494598c47fb
  1162. set "_key=PD3PC-RHNGV-FXJ29-8JK7D-RJRJK" &:: Visio Professional
  1163. exit /b
  1164. :aa2a7821-1827-4c2c-8f1d-4513a34dda97
  1165. set "_key=7WHWN-4T7MP-G96JF-G33KR-W8GF4" &:: Visio Standard
  1166. exit /b
  1167. :67c0fc0c-deba-401b-bf8b-9c8ad8395804
  1168. set "_key=GNH9Y-D2J4T-FJHGG-QRVH7-QPFDW" &:: Access
  1169. exit /b
  1170. :c3e65d36-141f-4d2f-a303-a842ee756a29
  1171. set "_key=9C2PK-NWTVB-JMPW8-BFT28-7FTBF" &:: Excel
  1172. exit /b
  1173. :d8cace59-33d2-4ac7-9b1b-9b72339c51c8
  1174. set "_key=DR92N-9HTF2-97XKM-XW2WJ-XW3J6" &:: OneNote
  1175. exit /b
  1176. :ec9d9265-9d1e-4ed0-838a-cdc20f2551a1
  1177. set "_key=R69KK-NTPKF-7M3Q4-QYBHW-6MT9B" &:: Outlook
  1178. exit /b
  1179. :d70b1bba-b893-4544-96e2-b7a318091c33
  1180. set "_key=J7MQP-HNJ4Y-WJ7YM-PFYGF-BY6C6" &:: Powerpoint
  1181. exit /b
  1182. :041a06cb-c5b8-4772-809f-416d03d16654
  1183. set "_key=F47MM-N3XJP-TQXJ9-BP99D-8K837" &:: Publisher
  1184. exit /b
  1185. :83e04ee1-fa8d-436d-8994-d31a862cab77
  1186. set "_key=869NQ-FJ69K-466HW-QYCP2-DDBV6" &:: Skype for Business
  1187. exit /b
  1188. :bb11badf-d8aa-470e-9311-20eaf80fe5cc
  1189. set "_key=WXY84-JN2Q9-RBCCQ-3Q3J3-3PFJ6" &:: Word
  1190. exit /b
  1191. :: Office 2013
  1192. :1dc00701-03af-4680-b2af-007ffc758a1f
  1193. set "_key=CWH2Y-NPYJW-3C7HD-BJQWB-G28JJ" &:: MondoR
  1194. exit /b
  1195. :dc981c6b-fc8e-420f-aa43-f8f33e5c0923
  1196. set "_key=42QTK-RN8M7-J3C4G-BBGYM-88CYV" &:: Mondo
  1197. exit /b
  1198. :b322da9c-a2e2-4058-9e4e-f59a6970bd69
  1199. set "_key=YC7DK-G2NP3-2QQC3-J6H88-GVGXT" &:: Professional Plus
  1200. exit /b
  1201. :b13afb38-cd79-4ae5-9f7f-eed058d750ca
  1202. set "_key=KBKQT-2NMXY-JJWGP-M62JB-92CD4" &:: Standard
  1203. exit /b
  1204. :4a5d124a-e620-44ba-b6ff-658961b33b9a
  1205. set "_key=FN8TT-7WMH6-2D4X9-M337T-2342K" &:: Project Professional
  1206. exit /b
  1207. :427a28d1-d17c-4abf-b717-32c780ba6f07
  1208. set "_key=6NTH3-CW976-3G3Y2-JK3TX-8QHTT" &:: Project Standard
  1209. exit /b
  1210. :e13ac10e-75d0-4aff-a0cd-764982cf541c
  1211. set "_key=C2FG9-N6J68-H8BTJ-BW3QX-RM3B3" &:: Visio Professional
  1212. exit /b
  1213. :ac4efaf0-f81f-4f61-bdf7-ea32b02ab117
  1214. set "_key=J484Y-4NKBF-W2HMG-DBMJC-PGWR7" &:: Visio Standard
  1215. exit /b
  1216. :6ee7622c-18d8-4005-9fb7-92db644a279b
  1217. set "_key=NG2JY-H4JBT-HQXYP-78QH9-4JM2D" &:: Access
  1218. exit /b
  1219. :f7461d52-7c2b-43b2-8744-ea958e0bd09a
  1220. set "_key=VGPNG-Y7HQW-9RHP7-TKPV3-BG7GB" &:: Excel
  1221. exit /b
  1222. :fb4875ec-0c6b-450f-b82b-ab57d8d1677f
  1223. set "_key=H7R7V-WPNXQ-WCYYC-76BGV-VT7GH" &:: Groove
  1224. exit /b
  1225. :a30b8040-d68a-423f-b0b5-9ce292ea5a8f
  1226. set "_key=DKT8B-N7VXH-D963P-Q4PHY-F8894" &:: InfoPath
  1227. exit /b
  1228. :1b9f11e3-c85c-4e1b-bb29-879ad2c909e3
  1229. set "_key=2MG3G-3BNTT-3MFW9-KDQW3-TCK7R" &:: Lync
  1230. exit /b
  1231. :efe1f3e6-aea2-4144-a208-32aa872b6545
  1232. set "_key=TGN6P-8MMBC-37P2F-XHXXK-P34VW" &:: OneNote
  1233. exit /b
  1234. :771c3afa-50c5-443f-b151-ff2546d863a0
  1235. set "_key=QPN8Q-BJBTJ-334K3-93TGY-2PMBT" &:: Outlook
  1236. exit /b
  1237. :8c762649-97d1-4953-ad27-b7e2c25b972e
  1238. set "_key=4NT99-8RJFH-Q2VDH-KYG2C-4RD4F" &:: Powerpoint
  1239. exit /b
  1240. :00c79ff1-6850-443d-bf61-71cde0de305f
  1241. set "_key=PN2WF-29XG2-T9HJ7-JQPJR-FCXK4" &:: Publisher
  1242. exit /b
  1243. :d9f5b1c6-5386-495a-88f9-9ad6b41ac9b3
  1244. set "_key=6Q7VD-NX8JD-WJ2VH-88V73-4GBJ7" &:: Word
  1245. exit /b
  1246. :embdbin:
  1247. function UninstallLicenses($DllPath) {
  1248. $TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2).DefineType(0)
  1249. [void]$TB.DefinePInvokeMethod('SLOpen', $DllPath, 22, 1, [int], @([IntPtr].MakeByRefType()), 1, 3)
  1250. [void]$TB.DefinePInvokeMethod('SLGetSLIDList', $DllPath, 22, 1, [int],
  1251. @([IntPtr], [int], [Guid].MakeByRefType(), [int], [int].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
  1252. [void]$TB.DefinePInvokeMethod('SLUninstallLicense', $DllPath, 22, 1, [int], @([IntPtr], [IntPtr]), 1, 3)
  1253. $SPPC = $TB.CreateType()
  1254. $Handle = 0
  1255. [void]$SPPC::SLOpen([ref]$Handle)
  1256. $pnReturnIds = 0
  1257. $ppReturnIds = 0
  1258. if (!$SPPC::SLGetSLIDList($Handle, 0, [ref][Guid]"0ff1ce15-a989-479d-af46-f275c6370663", 6, [ref]$pnReturnIds, [ref]$ppReturnIds)) {
  1259. foreach ($i in 0..($pnReturnIds - 1)) {
  1260. [void]$SPPC::SLUninstallLicense($Handle, [Int64]$ppReturnIds + [Int64]16 * $i)
  1261. }
  1262. }
  1263. }
  1264. $OSPP = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform" -ErrorAction SilentlyContinue).Path
  1265. if ($OSPP) {
  1266. UninstallLicenses ($OSPP + "osppc.dll")
  1267. }
  1268. UninstallLicenses "sppc.dll"
  1269. :embdbin:
  1270. :embdxrm:
  1271. $wmi = Get-WmiObject $sls
  1272. function InstallLicenseFile($Lsc) {
  1273. try {
  1274. $null = $wmi.InstallLicense([IO.File]::ReadAllText($Lsc))
  1275. } catch {
  1276. $host.SetShouldExit($_.Exception.HResult)
  1277. }
  1278. }
  1279. function InstallLicenseArr($Str) {
  1280. $a = $Str -split ';'
  1281. ForEach ($x in $a) {InstallLicenseFile "$x"}
  1282. }
  1283. function InstallLicenseDir($Loc) {
  1284. dir $Loc *.xrm-ms -af -s | select -expand FullName | % {InstallLicenseFile "$_"}
  1285. }
  1286. function ReinstallLicenses() {
  1287. $Oem = "$env:SystemRoot\system32\oem"
  1288. $Spp = "$env:SystemRoot\system32\spp\tokens"
  1289. InstallLicenseDir "$Spp"
  1290. If (Test-Path $Oem) {InstallLicenseDir "$Oem"}
  1291. }
  1292. :embdxrm:
  1293. :E_Admin
  1294. echo %_err%
  1295. echo This script requires administrator privileges.
  1296. echo To do so, right-click on this script and select 'Run as administrator'
  1297. goto :E_Exit
  1298. :E_PWS
  1299. echo %_err%
  1300. echo Windows PowerShell is not installed.
  1301. echo It is required for this script to work.
  1302. goto :E_Exit
  1303. :E_VBS
  1304. echo %_err%
  1305. echo VBScript engine is not installed.
  1306. echo It is required for this script to work.
  1307. goto :E_Exit
  1308. :E_WSH
  1309. echo %_err%
  1310. echo Windows Script Host is disabled.
  1311. echo It is required for this script to work.
  1312. goto :E_Exit
  1313. :E_WMI
  1314. echo %_err%
  1315. echo This script require one of these to work:
  1316. echo wmic.exe tool
  1317. echo VBScript engine
  1318. echo Windows PowerShell
  1319. goto :E_Exit
  1320. :TheEnd
  1321. if exist "%_temp%\crv*.txt" del /f /q "%_temp%\crv*.txt"
  1322. echo.
  1323. echo %_ln%
  1324. echo %msg%
  1325. echo %_ln%
  1326. goto :E_Exit
  1327. :E_Exit
  1328. if %_Debug% EQU 1 goto :eof
  1329. echo.
  1330. echo Press any key to exit.
  1331. pause >nul
  1332. goto :eof
  1333. :qrPKey
  1334. if %_cwmi% EQU 1 (
  1335. set "_qr=wmic path %1 where Version='%2' call InstallProductKey ProductKey="%3""
  1336. exit /b
  1337. )
  1338. if %WMI_VBS% NEQ 0 (
  1339. set "_qr=%_csp% %1 "%3""
  1340. exit /b
  1341. )
  1342. set _qr=%_psc% "try {$null=([WMI]'%1=''%2''').InstallProductKey('%3')} catch {$host.SetShouldExit($_.Exception.HResult)}"
  1343. exit /b
  1344. :qrMethod
  1345. if %_cwmi% EQU 1 (
  1346. set "_qr=wmic path %1 where %2='%3' call %4"
  1347. exit /b
  1348. )
  1349. if %WMI_VBS% NEQ 0 (
  1350. set "_qr=%_csm% "%1.%2='%3'" %4"
  1351. exit /b
  1352. )
  1353. set _qr=%_psc% "try {$null=([WMI]'%1.%2=''%3''').%4()} catch {$host.SetShouldExit($_.Exception.HResult)}"
  1354. exit /b
  1355. :qrSingle
  1356. if %_cwmi% EQU 1 (
  1357. set "_qr=wmic path %1 get %2 /value"
  1358. exit /b
  1359. )
  1360. if %WMI_VBS% NEQ 0 (
  1361. set "_qr=%_csq% %1 %2"
  1362. exit /b
  1363. )
  1364. set _qr=%_psc% "(([WMISEARCHER]'SELECT %2 FROM %1').Get()).Properties | %% {$_.Name+'='+$_.Value}"
  1365. exit /b
  1366. :qrQuery
  1367. set "_quxt="
  1368. set "_quxt=%~4"
  1369. if %_cwmi% EQU 1 (
  1370. set "_qr=wmic path %1 where "%~2" get %3 /value"
  1371. if defined _quxt set "_qr=wmic path %1 where "%~2" get %3"
  1372. exit /b
  1373. )
  1374. if %WMI_VBS% NEQ 0 (
  1375. set "_qr=%_csq% %1 "%~2" %3"
  1376. exit /b
  1377. )
  1378. set "_rq=%~2"
  1379. set "_rq=%_rq:'=''%"
  1380. set _qr=%_psc% "(([WMISEARCHER]'SELECT %3 FROM %1 WHERE %_rq%').Get()).Properties | %% {$_.Name+'='+$_.Value}"
  1381. exit /b
  1382. ----- Begin wsf script --->
  1383. <package>
  1384. <job id="WmiQuery">
  1385. <script language="VBScript">
  1386. If WScript.Arguments.Count = 3 Then
  1387. wExc = "Select " & WScript.Arguments.Item(2) & " from " & WScript.Arguments.Item(0) & " where " & WScript.Arguments.Item(1)
  1388. wGet = WScript.Arguments.Item(2)
  1389. Else
  1390. wExc = "Select " & WScript.Arguments.Item(1) & " from " & WScript.Arguments.Item(0)
  1391. wGet = WScript.Arguments.Item(1)
  1392. End If
  1393. Set objCol = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
  1394. For Each objItm in objCol
  1395. For each Prop in objItm.Properties_
  1396. If LCase(Prop.Name) = LCase(wGet) Then
  1397. WScript.Echo Prop.Name & "=" & Prop.Value
  1398. Exit For
  1399. End If
  1400. Next
  1401. Next
  1402. </script>
  1403. </job>
  1404. <job id="WmiMethod">
  1405. <script language="VBScript">
  1406. On Error Resume Next
  1407. wPath = WScript.Arguments.Item(0)
  1408. wMethod = WScript.Arguments.Item(1)
  1409. Set objCol = GetObject("winmgmts:\\.\root\CIMV2:" & wPath)
  1410. objCol.ExecMethod_(wMethod)
  1411. WScript.Quit Err.Number
  1412. </script>
  1413. </job>
  1414. <job id="WmiPKey">
  1415. <script language="VBScript">
  1416. On Error Resume Next
  1417. wExc = "SELECT Version FROM " & WScript.Arguments.Item(0)
  1418. wKey = WScript.Arguments.Item(1)
  1419. Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
  1420. For each colService in objWMIService
  1421. Exit For
  1422. Next
  1423. set objService = colService
  1424. objService.InstallProductKey(wKey)
  1425. WScript.Quit Err.Number
  1426. </script>
  1427. </job>
  1428. </package>