2025-05-06 17:06:13 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								@ set  masver = 3.2
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								@ echo  off
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :============================================================================ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: : 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :   Homepage: mass grave[.]dev 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :      Email: mas.help@outlook.com 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :============================================================================ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Set environment variables, it helps if they are misconfigured in the system 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								setlocal  EnableExtensions
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								setlocal  DisableDelayedExpansion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " SysPath= %SystemRoot% \System32 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " Path= %SystemRoot% \System32; %SystemRoot% ; %SystemRoot% \System32\Wbem; %SystemRoot% \System32\WindowsPowerShell\v1.0\ " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  exist  " %SystemRoot% \Sysnative\reg.exe "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " SysPath= %SystemRoot% \Sysnative " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " Path= %SystemRoot% \Sysnative; %SystemRoot% ; %SystemRoot% \Sysnative\Wbem; %SystemRoot% \Sysnative\WindowsPowerShell\v1.0\; %Path% " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " ComSpec= %SysPath% \cmd.exe " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " PSModulePath= %ProgramFiles% \WindowsPowerShell\Modules; %SysPath% \WindowsPowerShell\v1.0\Modules " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 14:49:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  re1 = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  re2 = 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  " _cmdf= %~f0 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( %* )  do  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 14:49:09 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  /i  " %% # " == " re1 "  set  re1 = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  /i  " %% # " == " re2 "  set  re2 = 1
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: : Re-launch the script with x64 process if it was initiated by x86 process on x64 bit Windows 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: : or with ARM64 process if it was initiated by x86/ARM32 process on ARM64 Windows 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 04:59:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  exist  %SystemRoot% \Sysnative\cmd.exe if  not  defined  re1  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								setlocal  EnableDelayedExpansion
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 04:59:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								start  %SystemRoot% \Sysnative\cmd.exe /c " " !_cmdf! "   %*  re1 " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: : Re-launch the script with ARM32 process if it was initiated by x64 process on ARM64 Windows 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 04:59:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  exist  %SystemRoot% \SysArm32\cmd.exe if  %PROCESSOR_ARCHITECTURE% == AMD64 if  not  defined  re2  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								setlocal  EnableDelayedExpansion
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 04:59:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								start  %SystemRoot% \SysArm32\cmd.exe /c " " !_cmdf! "   %*  re2 " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " blank= " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-30 20:24:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " mas=ht %blank% tps %blank% ://mass %blank% grave.dev/ " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Check if Null service is working, it's important for the batch script 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								sc query Null |  find /i " RUNNING " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel%  NEQ  0 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Null service is not running, script may crash...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2025-03-15 21:34:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Check this webpage for help - %mas% fix_service
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								ping 127.0.0.1 -n 20
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Check LF line ending 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								pushd  " %~dp0 " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								> nul findstr /v " $ "  " %~nx0 "  &&  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Error - Script either has LF line ending issue or an empty line at the end of the script is missing.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2025-03-15 21:34:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Check this webpage for help - %mas% troubleshoot
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								ping 127.0.0.1 -n 20 > nul
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								popd 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								popd 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								color  07
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								title   Troubleshoot %masver% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  _args = 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  _elev = 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  _unattended = 0
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  _args = %* 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  _args  set  _args = %_args:"=% 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 04:59:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  _args  set  _args = %_args:re1=% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  _args  set  _args = %_args:re2=% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  _args  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% A in  ( %_args% )  do  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  /i  " %% A " == " -el "                     set  _elev = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " nul1=1>nul " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " nul2=2>nul " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " nul6=2 ^ >nul " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  " nul=>nul 2>&1 " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_setvar 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  " line=_________________________________________________________________________________________________ " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-13 17:40:49 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  EQU  1 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Failed to detect Windows build number.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								setlocal  EnableDelayedExpansion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  fixes = %fixes%  %mas% troubleshoot
							 
						 
					
						
							
								
									
										
										
										
											2025-03-15 21:34:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %Blue%  " Check this webpage for help -  "  %_Yellow%  "   %mas% troubleshoot " 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-13 17:40:49 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  6001 ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								%nceline% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Unsupported OS version detected [%winbuild% ].
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  MAS only supports Windows Vista/7/8/8.1/10/11 and their Server equivalents.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  EQU  6000 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Windows Vista RTM is not supported because Powershell cannot be installed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Upgrade to Windows Vista SP1 or SP2.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 13:59:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  7600 if  not  exist  " %SysPath% \WindowsPowerShell\v1.0\Modules "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%nceline% 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 13:59:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  exist  %ps%  ( 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  PowerShell is not installed in your system.
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 13:59:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Install PowerShell 2.0 using the following URL.
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930
							 
						 
					
						
							
								
									
										
										
										
											2025-04-21 14:52:13 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %_unattended% == 0 start  https://www.catalog.update.microsoft.com/Search.aspx?q=KB968930
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Fix special character limitations in path name 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _work= %~dp0 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  " %_work:~-1% " == " \ "  set  " _work= %_work:~0,-1% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _batf= %~f0 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _batp= %_batf:'=''% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  _PSarg = " " " %~f0 " " "  -el %_args% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  _PSarg = %_PSarg:'=''% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " _ttemp= %userprofile% \AppData\Local\Temp " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								setlocal  EnableDelayedExpansion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  " !_batf! "  |  find /i " !_ttemp! "  %nul1%  &&  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  /i  not  " !_work! " == " !_ttemp! "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  The script was launched from the temp folder.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  You are most likely running the script directly from the archive file.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Extract the archive file and launch the script from the extracted folder.
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-23 15:06:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Elevate script as admin and pass arguments and preventing loop 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%nul1%  fltmc ||  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  _elev  %psc%  " start cmd.exe -arg '/c \ " !_PSarg! \" ' -verb runas "  &&  exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  This script needs admin rights.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Right click on this script and select 'Run as administrator'.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Check PowerShell 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-23 15:06:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :pstst $ExecutionContext.SessionState.LanguageMode :pstst 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 21:41:21 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  /f  " delims= "  %% a in  ( ' %psc%  "if ($PSVersionTable.PSEdition -ne 'Core' )  {$f=[io.file]::ReadAllText('!_batp!')  -split ':pstst';iex ($f[1])}"  %nul6% ' )  do  ( set  tstresult = %% a) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-23 19:06:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  /i  not  " %tstresult% " == " FullLanguage "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-12 22:15:34 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo : %tstresult% 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-23 19:06:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								cmd /c " %psc%  $ExecutionContext.SessionState.LanguageMode " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								REM check LanguageMode 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cmd /c " %psc%   " $ExecutionContext.SessionState.LanguageMode" "  |  findstr /i " ConstrainedLanguage RestrictedLanguage NoLanguage "  %nul1%  &&  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  FullLanguage mode not found in PowerShell. Aborting...
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  If you have applied restrictions on Powershell then undo those changes.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  fixes = %fixes%  %mas% fix_powershell
							 
						 
					
						
							
								
									
										
										
										
											2025-03-15 21:34:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %Blue%  " Check this webpage for help -  "  %_Yellow%  "   %mas% fix_powershell " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-23 19:06:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								REM check Powershell core version 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cmd /c " %psc%   " $PSVersionTable.PSEdition" "  |  find /i " Core "  %nul1%  &&  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-12 22:55:10 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								REM check for Mal-ware that may cause issues with Powershell 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /r " %ProgramFiles% \ "  %% f in  ( secureboot.exe)  do  if  exist  " %% f "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  " %% f " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Mal%blank% ware found, PowerShell is not working properly.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  fixes = %fixes%  %mas% remove_mal%w% ware
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : dk_color2  %Blue%  " Check this webpage for help -  "  %_Yellow%  "   %mas% remove_mal %w% ware " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-23 19:06:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								REM check antivirus and other errors 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-23 15:06:55 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  PowerShell is not working properly. Aborting...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cmd /c " %psc%   " " $av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue } " " " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  fixes = %fixes%  %mas% troubleshoot
							 
						 
					
						
							
								
									
										
										
										
											2025-03-15 21:34:40 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %Blue%  " Check this webpage for help -  "  %_Yellow%  "   %mas% troubleshoot " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Disable QuickEdit and launch from conhost.exe to avoid Terminal app 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  GEQ  17763 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  terminal = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  terminal = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Check if script is running in Terminal app 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  terminal  ( 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-13 22:40:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  lines = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2 delims=:  "  %% A in  ( 'mode con' )  do  if  " !lines! " == " 0 "  set  lines = %% A
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  !lines!  GEQ  100 set  terminal = 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %_unattended% == 1 goto  : skipQE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( %_args% )  do  ( if  /i  " %% # " == " -qedit "  goto  : skipQE ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-13 22:40:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Relaunch to disable QuickEdit in the current session and use conhost.exe instead of the Terminal app 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  This code disables QuickEdit for the current cmd.exe session without making permanent registry changes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  It is included because clicking on the script window can pause execution, causing confusion that the script has stopped due to an error 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-13 22:40:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  resetQE = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg query HKCU\Console /v QuickEdit %nul2%  |  find /i " 0x0 "  %nul1%  &&  set  resetQE = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg add HKCU\Console /v QuickEdit /t REG_DWORD /d 0 /f %nul1% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-13 22:40:58 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  terminal  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								start  conhost.exe " !_batf! "  %_args%  -qedit
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								start  reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE%  /f %nul1% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else if %resetQE% EQU 1 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								start  cmd.exe /c " " !_batf! "   %_args%  -qedit " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								start  reg add HKCU\Console /v QuickEdit /t REG_DWORD /d %resetQE%  /f %nul1% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: skipQE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Check for updates 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  - = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  old = 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-22 15:22:26 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  pingp = 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-13 17:40:49 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  upver = %masver:.=% 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-22 15:22:26 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  %% A in  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								activ%-% ated.win
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								mass%-% grave.dev
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) do if not defined pingp ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " delims=[] tokens=2 "  %% B in  ( 'ping -n 1  %% A' )  do  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  " %% B " == " "  ( set  old = 1&  set  pingp = 1) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " delims=[] tokens=2 "  %% C in  ( 'ping -n 1 updatecheck %upver% . %% A' )  do  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  " %% C " == " "  set  old = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-13 17:40:49 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  old  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  ________________________________________________
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Your version of MAS [%masver% ] is outdated.
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  ________________________________________________
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  %_unattended% == 1 ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  [1] Get Latest MAS
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  [0] Continue Anyway
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Green%  " Choose a menu option using your keyboard [1,0] : " 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								choice /C:10 /N
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 2 rem 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-18 06:39:25 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 1 ( start  https://git.activated.win/massg%-% rave/Micr%-% osoft-Act%-% ivation-Scripts &  start  https://github.com/massgra%-% vel/Micro%-% soft-Acti%-% vation-Scripts &  start  %mas%  &  exit  /b) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								setlocal  DisableDelayedExpansion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Check desktop location 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  desktop = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( 'reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop' )  do  call  set  " desktop= %% b " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  desktop  for  /f  " delims= "  %% a in  ( ' %psc%  "& {write-host $([Environment]::GetFolderPath('Desktop' ) ) }" ') do call set  " desktop=%% a" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  desktop  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Unable to detect Desktop location, aborting...
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								goto  dk_done 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								setlocal  EnableDelayedExpansion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: at_menu 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								color  07
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								title   Troubleshoot %masver% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  defined  terminal  mode 77, 30
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :       _______________________________________________________________
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :                                                   
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %_White%  "              [1]  "  %_Green%  " Help " 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :             ___________________________________________________
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :                                                                      
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :             [2] Dism RestoreHealth
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :             [3] SFC Scannow
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :                                                                      
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :             [4] Fix WMI
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :             [5] Fix Licensing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :             [6] Fix WPA Registry
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :             ___________________________________________________
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :             [0] %_exitmsg% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :       _______________________________________________________________
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :          
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %_White%  "              "  %_Green%  " Choose a menu option using your keyboard : " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								choice /C:1234560 /N
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  _erl = %errorlevel% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %_erl% == 7 exit  /b
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %_erl% == 6 start  %mas% fix-wpa-registry & goto  at_menu 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %_erl% == 5 goto : retokens 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %_erl% == 4 goto : fixwmi 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %_erl% == 3 goto : sfcscan 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %_erl% == 2 goto : dism_rest 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-30 20:24:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %_erl% == 1 start  %mas% troubleshoot.html & goto  at_menu 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_menu 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: dism_rest 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  defined  terminal  mode 98, 30
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								title   Dism /English /Online /Cleanup-Image /RestoreHealth
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  9200 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Unsupported OS version detected.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  This command only works on Windows 8/8.1/10/11 and their Server equivalents.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  _int = 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								for  %% a in  ( l.root-servers.net resolver1.opendns.com download.windowsupdate.com google.com)  do  if  not  defined  _int  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 23:59:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  /f  " delims=[] tokens=2 "  %% # in  ( 'ping -n 1  %% a' )  do  ( if  not  " %% # " == " "  set  _int = 1) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  _int  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo       Checking Internet Connection  [Connected]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %_White%  "       "  %Red%  " Checking Internet Connection  [Not connected] " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo       DISM uses Windows Update to provide replacement files required to fix corruption.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo       This will take 5-15 minutes or more..
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo       Notes:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %_White%  "      -  "  %Gray%  " Make sure the internet is connected. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : dk_color2  %_White%  "      -  "  %Gray%  " Make sure that Windows update is properly working. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								choice /C:09 /N /M " >    [9] Continue [0] Go back :  " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel% == 1 goto  at_menu 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  defined  terminal  mode 110, 30
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  %% a in  ( ' %psc%  "(Get-Date).ToString('yyyyMMdd-HHmmssfff' ) " ') do set _time= %% a 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service TrustedInstaller -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\cbs\cbs.log "  " %SystemRoot% \logs\cbs\backup_cbs_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\DISM\dism.log "  " %SystemRoot% \logs\DISM\backup_dism_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								del  /f /q " %SystemRoot% \logs\cbs\cbs.log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								del  /f /q " %SystemRoot% \logs\DISM\dism.log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Applying the command...
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  dism /english /online /cleanup-image /restorehealth
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								dism /english /online /cleanup-image /restorehealth
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								timeout /t 5 %nul1% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\cbs\cbs.log "  " %SystemRoot% \logs\cbs\cbs_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\DISM\dism.log "  " %SystemRoot% \logs\DISM\dism_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  exist  " !desktop! \AT_Logs\ "  md  " !desktop! \AT_Logs\ "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : compresslog  cbs\cbs_%_time% .log AT_Logs\RHealth_CBS %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : compresslog  DISM\dism_%_time% .log AT_Logs\RHealth_DISM %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  exist  " !desktop! \AT_Logs\RHealth_CBS_ %_time% .cab "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\cbs\cbs.log "  " !desktop! \AT_Logs\RHealth_CBS_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  exist  " !desktop! \AT_Logs\RHealth_DISM_ %_time% .cab "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\DISM\dism.log "  " !desktop! \AT_Logs\RHealth_DISM_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Gray%  " CBS and DISM logs are copied to the AT_Logs folder on your desktop. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: sfcscan 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  defined  terminal  mode 98, 30
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								title   sfc /scannow
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :    
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo       SFC will repair missing or corrupted system files.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo       It is recommended you run the DISM option first before this one.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo       This will take 10-15 minutes or more..
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo       If SFC could not fix something, then run the command again to see if it may be able 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo       to the next time. Sometimes it may take running the sfc /scannow command 3 times
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo       restarting the PC after each time to completely fix everything that it's able to.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								choice /C:09 /N /M " >    [9] Continue [0] Go back :  " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel% == 1 goto  at_menu 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  /f  %% a in  ( ' %psc%  "(Get-Date).ToString('yyyyMMdd-HHmmssfff' ) " ') do set _time= %% a 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service TrustedInstaller -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\cbs\cbs.log "  " %SystemRoot% \logs\cbs\backup_cbs_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								del  /f /q " %SystemRoot% \logs\cbs\cbs.log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Applying the command...
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  sfc /scannow
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								sfc /scannow
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								timeout /t 5 %nul1% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\cbs\cbs.log "  " %SystemRoot% \logs\cbs\cbs_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  not  exist  " !desktop! \AT_Logs\ "  md  " !desktop! \AT_Logs\ "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : compresslog  cbs\cbs_%_time% .log AT_Logs\SFC_CBS %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  exist  " !desktop! \AT_Logs\SFC_CBS_ %_time% .cab "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								copy  /y /b " %SystemRoot% \logs\cbs\cbs.log "  " !desktop! \AT_Logs\SFC_CBS_ %_time% .log "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Gray%  " The CBS log was copied to the AT_Logs folder on your Desktop. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: retokens 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 01:38:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  defined  terminal  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								mode 125, 32
							 
						 
					
						
							
								
									
										
										
										
											2024-10-21 22:06:28 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  " &{$W=$Host.UI.RawUI.WindowSize;$B=$Host.UI.RawUI.BufferSize;$W.Height=31;$B.Height=200;$Host.UI.RawUI.WindowSize=$W;$Host.UI.RawUI.BufferSize=$B;} "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 01:38:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								title   Fix Licensing ^( ClipSVC ^+  SPP ^+  OSPP^) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  EQU  6001 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  This option is not supported on Windows Vista SP1.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Upgrade to Windows Vista SP2.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :   
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo       Notes:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo        - This option helps in troubleshooting activation issues.
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo        - This option will:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo             - Deactivate Windows and Office, you may need to reactivate.
							 
						 
					
						
							
								
									
										
										
										
											2024-08-28 03:00:14 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo               If Windows is activated with motherboard / OEM / Digital license
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo               then Windows will activate itself again.
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 02:50:03 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo             - Clear ClipSVC, SPP and OSPP licenses.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo             - Fix permissions of SPP tokens folder and registries.
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo             - Trigger the repair option for Office.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %_White%  "       -  "  %Blue%  " Apply this option only when it is necessary. " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								choice /C:09 /N /M " >    [9] Continue [0] Go back :  " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel% == 1 goto  at_menu 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Rebuild ClipSVC Licences 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: cleanlicensing 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Blue%  " Rebuilding ClipSVC Licenses... " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  10240 ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  ClipSVC license rebuilding is supported only on Windows 10/11 and their Server equivalents.
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Skipping...
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 01:38:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								goto  : rebuildspptok 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 01:38:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  " (([WMISEARCHER]'SELECT Name FROM SoftwareLicensingProduct WHERE LicenseStatus=1 AND GracePeriodRemaining=0 AND PartialProductKey IS NOT NULL AND LicenseDependsOn is NULL').Get()).Name "  %nul2%  |  findstr /i " Windows "  %nul1%  &&  ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Windows is permanently activated.
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 01:38:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Skipping...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  : rebuildspptok 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Stopping ClipSVC service...
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service ClipSVC -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								timeout /t 2 %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Applying the command to clean ClipSVC Licenses...
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  rundll32 clipc.dll,ClipCleanUpState
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								rundll32 clipc.dll,ClipCleanUpState
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  LEQ  10240 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  " %ProgramData% \Microsoft\Windows\ClipSVC\tokens.dat "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Below registry key (Volatile & Protected) gets created after the ClipSVC License cleanup command, and gets automatically deleted after  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  system restart. It needs to be deleted to activate the system without restart. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " RegKey=HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _ident=HKU\S-1-5-19\SOFTWARE\Microsoft\IdentityCRL " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg query " %RegKey% "  %nul%  &&  %nul%  call :regownstart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg delete " %RegKey% "  /f %nul%  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Deleting a Volatile ^&  Protected Registry Key...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [%RegKey% ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg query " %RegKey% "  %nul%  &&  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-31 21:20:49 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Reboot your machine using the restart option, that will delete this registry key automatically.
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) || ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :   Clear HWID token related registry to fix activation incase there is any corruption 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Deleting IdentityCRL Registry Key...
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  [%_ident% ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg delete " %_ident% "  /f %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg query " %_ident% "  %nul%  &&  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) || ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service ClipSVC -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Rebuild ClipSVC folder to fix permission issues 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  GTR  10240 ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Deleting folder %ProgramData% \Microsoft\Windows\ClipSVC\
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								rmdir  /s /q " C:\ProgramData\Microsoft\Windows\ClipSvc "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  " %ProgramData% \Microsoft\Windows\ClipSVC\ "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Rebuilding the %ProgramData% \Microsoft\Windows\ClipSVC\ folder...
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Start-Service ClipSVC %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								timeout /t 3 %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  exist  " %ProgramData% \Microsoft\Windows\ClipSVC\ "  timeout /t 5 %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  exist  " %ProgramData% \Microsoft\Windows\ClipSVC\ "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Restarting wlidsvc ^&  LicenseManager services...
							 
						 
					
						
							
								
									
										
										
										
											2024-11-03 03:01:56 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  %% # in  ( wlidsvc LicenseManager)  do  ( %psc%  " Start-Job { Restart-Service  %% # } | Wait-Job -Timeout 20 | Out-Null " ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :  Rebuild SPP Tokens 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 01:38:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: rebuildspptok 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Blue%  " Rebuilding SPP licensing tokens... " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandat  check
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  token  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " tokens.dat file not found. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  tokens.dat file: [%token% ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  tokenstore = 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  badregistry = 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( 'reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /v TokenStore  %nul6% ' )  do  call  set  " tokenstore= %% b " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  GEQ  9200 if  /i  not  " %tokenstore% " == " %SysPath% \spp\store "  if  /i  not  " %tokenstore% " == " %SysPath% \spp\store\2.0 "  if  /i  not  " %tokenstore% " == " %SysPath% \spp\store_test\2.0 "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  badregistry = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " Correct path not found in TokenStore Registry [ %tokenstore% ] " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Check sppsvc permissions and apply fixes 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  GEQ  9200 if  not  defined  badregistry  ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Checking SPP permission related issues...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : checkperms 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  permerror  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [!permerror!] " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  " $f=[io.file]::ReadAllText('!_batp!') -split ':fixsppperms\:.*';iex ($f[1]) "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								call  : checkperms 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  permerror  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [!permerror!] [Failed To Fix] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Green%  " [Successfully Fixed] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  [No Error Found]
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Stopping %_slser%  service...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service %_slser%  -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-29 21:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  w = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  _sppint = 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  %% # in  ( SppEx%w% tComObj.exe %_slexe% )  do  ( reg query " HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima %w% ge File Execu %w% tion Options\ %% # "  %nul%  &&  ( set  _sppint = 1) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-29 21:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  _sppint  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Removing SPP IFEO registry keys...
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  %% # in  ( SppE%w% xtComObj.exe %_slexe% )  do  ( reg delete " HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ima %w% ge File Execu %w% tion Options\ %% # "  /f %nul% ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-29 21:28:38 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  9200 if  not  defined  _vis  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 13:10:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								REM Fix issues caused by Update KB971033 in Windows 7 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 00:01:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								REM https://support.microsoft.com/en-us/help/4487266 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 13:10:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Checking Update KB971033...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  " if (Get-Hotfix -Id KB971033 -ErrorAction SilentlyContinue) {Exit 3} "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 3 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Found, uninstalling it...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								wusa /uninstall /quiet /norestart /kb:971033
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Not Found]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service sppuinotify -force %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								sc config sppuinotify start= disabled
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								del  /f /q %SysPath% \7B296FB0-376B-497e-B012-9C450E1B7327-*.C7483456-A289-439d-8115-601632D005A0 /ah
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 21:43:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Delete registry keys that are not deleted by activation scripts 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  defined  _vis  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 22:21:13 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Cleaning some licensing-related registry keys...
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 21:43:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%nul%  reg delete " HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform "  /v " ServiceSessionId "  /f
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%nul%  reg delete " HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform "  /v " LicStatusArray "  /f
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%nul%  reg delete " HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform "  /v " PolicyValuesArray "  /f
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%nul%  reg delete " HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform "  /v " actionlist "  /f
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%nul%  reg delete " HKLM\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform\data "  /f
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 21:43:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandat  delete
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandat  check
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  token  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " Failed to delete .dat files. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  _vis  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  Start-Service %_slser%  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Reinstalling system licenses...
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  " $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %errorlevel%  NEQ  0 %psc%  " $sls = Get-WmiObject SoftwareLicensingService; $f=[io.file]::ReadAllText('!_batp!') -split ':xrm\:.*';iex ($f[1]); ReinstallLicenses "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel%  EQU  0 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandat  check
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  token  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " Failed to rebuild tokens.dat file. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  tokens.dat file was rebuilt successfully.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  9200 if  not  defined  _vis  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 13:10:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								sc config sppuinotify start= demand
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Rebuild OSPP Tokens 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Blue%  " Rebuilding OSPP licensing tokens... " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								sc qc osppsvc %nul%  ||  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  OSPP-based Office is not installed.
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Skipping rebuilding OSPP tokens...
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : repairoffice 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandatospp  check
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  token  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " tokens.dat file not found. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  tokens.dat file: [%token% ]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Stopping osppsvc service...
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service osppsvc -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandatospp  delete
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandatospp  check
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  token  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " Failed to delete .dat files. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Starting osppsvc service to generate tokens.dat...
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Start-Service osppsvc %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								call  : scandatospp  check
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  token  ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service osppsvc -force %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  Start-Service osppsvc %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								timeout /t 3 %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : scandatospp  check
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  token  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " Failed to rebuild tokens.dat file. " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  tokens.dat file was rebuilt successfully.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: repairoffice 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Blue%  " Repairing Office licenses... " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( 68 86)  do  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% A in  ( msi14 msi15 msi16 c2r14 c2r15 c2r16)  do  ( set  %% A_ %% # = & set  %% Arepair %% # = ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  _68 = HKLM\SOFTWARE\Microsoft\Office
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  _86 = HKLM\SOFTWARE\Wow6432Node\Microsoft\Office
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								reg query %_68% \14.0\CVH /f Click2run /k %nul%  &&  ( set  " c2r14_68=Office 14.0 C2R x86/x64 "   &  set  " c2r14repair68= " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg query %_86% \14.0\CVH /f Click2run /k %nul%  &&  ( set  " c2r14_86=Office 14.0 C2R x86 "       &  set  " c2r14repair86= " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 12:09:26 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_86% \14.0\Common\InstallRoot /v Path"  %nul6% ' )  do  if  exist  " %% b\*Picker.dll "  ( set  " msi14_86=Office 14.0 MSI x86 "       &  call  : getrepairsetup  msi14repair86 14) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_68% \14.0\Common\InstallRoot /v Path"  %nul6% ' )  do  if  exist  " %% b\*Picker.dll "  ( set  " msi14_68=Office 14.0 MSI x86/x64 "   &  call  : getrepairsetup  msi14repair68 14) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_86% \15.0\Common\InstallRoot /v Path"  %nul6% ' )  do  if  exist  " %% b\*Picker.dll "  ( set  " msi15_86=Office 15.0 MSI x86 "       &  call  : getrepairsetup  msi15repair86 15) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_68% \15.0\Common\InstallRoot /v Path"  %nul6% ' )  do  if  exist  " %% b\*Picker.dll "  ( set  " msi15_68=Office 15.0 MSI x86/x64 "   &  call  : getrepairsetup  msi15repair68 15) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_86% \16.0\Common\InstallRoot /v Path"  %nul6% ' )  do  if  exist  " %% b\*Picker.dll "  ( set  " msi16_86=Office 16.0 MSI x86 "       &  call  : getrepairsetup  msi16repair86 16) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_68% \16.0\Common\InstallRoot /v Path"  %nul6% ' )  do  if  exist  " %% b\*Picker.dll "  ( set  " msi16_68=Office 16.0 MSI x86/x64 "   &  call  : getrepairsetup  msi16repair68 16) 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-03 00:48:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_86% \15.0\ClickToRun /v InstallPath"  %nul6% ' )  do  if  exist  " %% b\root\Licenses\ProPlus*.xrm-ms "  ( set  " c2r15_86=Office 15.0 C2R x86 "       &  call  : getc2rrepair  c2r15repair86 integratedoffice.exe) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_68% \15.0\ClickToRun /v InstallPath"  %nul6% ' )  do  if  exist  " %% b\root\Licenses\ProPlus*.xrm-ms "  ( set  " c2r15_68=Office 15.0 C2R x86/x64 "   &  call  : getc2rrepair  c2r15repair68 integratedoffice.exe) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_86% \ClickToRun /v InstallPath"  %nul6% ' )  do  if  exist  " %% b\root\Licenses16\ProPlus*.xrm-ms "     ( set  " c2r16_86=Office 16.0 C2R x86 "       &  call  : getc2rrepair  c2r16repair86 OfficeClickToRun.exe) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " skip=2 tokens=2* "  %% a in  ( '"reg query  %_68% \ClickToRun /v InstallPath"  %nul6% ' )  do  if  exist  " %% b\root\Licenses16\ProPlus*.xrm-ms "     ( set  " c2r16_68=Office 16.0 C2R x86/x64 "   &  call  : getc2rrepair  c2r16repair68 OfficeClickToRun.exe) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  uwp16 = 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  GEQ  10240 ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  " Get-AppxPackage -name  " Microsoft.Office.Desktop" "  |  find /i " Office "  %nul1%  &&  set  uwp16 = Office 16.0 UWP
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  /a  counter = 0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Checking installed Office versions...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %msi14_68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %msi14_86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %msi15_68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %msi15_86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %msi16_68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %msi16_86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %c2r14_68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %c2r14_86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %c2r15_68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %c2r15_86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %c2r16_68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %c2r16_86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" %uwp16% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) do ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  " %% # " == " " " "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  insoff = %% #
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  insoff = !insoff:"=! 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [!insoff!]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  /a  counter += 1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %counter%  GTR  1 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Multiple Office versions found.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  It is recommended to only install one version of Office.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  ________________________________________________________________
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %counter%  EQU  0 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 13:37:39 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Office ^( 2010 and later^)  is not installed.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : repairend 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Yellow%  " A new window will appear, in that window you need to select [Quick Repair] option. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:38:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  terminal  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Yellow%  " Press [0] to continue... " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:38:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								choice /c 0 /n
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Yellow%  " Press any key to continue... " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								pause  %nul1% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:38:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  uwp16  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-11-03 00:48:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Skipping repair for Office 16.0 UWP... 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  c2r14 = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  c2r14_68  set  c2r14 = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  c2r14_86  set  c2r14 = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  c2r14  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-11-03 00:48:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Skipping repair for Office 14.0 C2R...
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  msi14_68  if  exist  " %msi14repair68% "  echo  Running - " %msi14repair68% "                     &  " %msi14repair68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  msi14_86  if  exist  " %msi14repair86% "  echo  Running - " %msi14repair86% "                     &  " %msi14repair86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  msi15_68  if  exist  " %msi15repair68% "  echo  Running - " %msi15repair68% "                     &  " %msi15repair68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  msi15_86  if  exist  " %msi15repair86% "  echo  Running - " %msi15repair86% "                     &  " %msi15repair86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  msi16_68  if  exist  " %msi16repair68% "  echo  Running - " %msi16repair68% "                     &  " %msi16repair68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  msi16_86  if  exist  " %msi16repair86% "  echo  Running - " %msi16repair86% "                     &  " %msi16repair86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  c2r15_68  if  exist  " %c2r15repair68% "  echo  Running - " %c2r15repair68% "  REPAIRUI RERUNMODE &  " %c2r15repair68% "  REPAIRUI RERUNMODE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  c2r15_86  if  exist  " %c2r15repair86% "  echo  Running - " %c2r15repair86% "  REPAIRUI RERUNMODE &  " %c2r15repair86% "  REPAIRUI RERUNMODE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  c2r16_68  if  exist  " %c2r16repair68% "  echo  Running - " %c2r16repair68% "  scenario=Repair    &  " %c2r16repair68% "  scenario=Repair
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  c2r16_86  if  exist  " %c2r16repair86% "  echo  Running - " %c2r16repair86% "  scenario=Repair    &  " %c2r16repair86% "  scenario=Repair
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: repairend 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Green%  " Finished " 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-03 00:48:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: getc2rrepair 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( X86 X64)  do  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  " %systemdrive% \Program Files\Microsoft Office 15\Client %% #\ %2 "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " %1 = %systemdrive% \Program Files\Microsoft Office 15\Client %% #\ %2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 14:23:05 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: getrepairsetup 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _common86= %systemdrive% \Program Files (x86)\Common Files\Microsoft Shared\OFFICE %2 \Office Setup Controller\setup.exe " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _common68= %systemdrive% \Program Files\Common Files\Microsoft Shared\OFFICE %2 \Office Setup Controller\setup.exe " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  " %_common86% "  set  " %1 = %_common86% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  " %_common68% "  set  " %1 = %_common68% " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: fixwmi 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								cls 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  defined  terminal  mode 98, 34
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								title   Fix WMI
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :  https://techcommunity.microsoft.com/t5/ask-the-performance-team/wmi-repository-corruption-or-not/ba-p/375484 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  exist  " %SystemRoot% \Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Rebuilding WMI is not recommended on Windows Server, aborting...
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Checking WMI
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : checkwmi 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Apply basic fix first and check 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  error  ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service Winmgmt -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								winmgmt /salvagerepository %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : checkwmi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  error  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  [Working]
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  No need to apply this option, aborting...
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Not Responding] " 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  _corrupt = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								sc start Winmgmt %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel%  EQU  1060 set  _corrupt = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								sc query Winmgmt %nul%  ||  set  _corrupt = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% G in  ( DependOnService Description DisplayName ErrorControl ImagePath ObjectName Start Type)  do  if  not  defined  _corrupt  ( reg query HKLM\SYSTEM\CurrentControlSet\Services\Winmgmt /v %% G %nul%  ||  set  _corrupt = 1) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  _corrupt  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								%eline% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  Winmgmt service is corrupted, aborting...
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Disabling Winmgmt service
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								sc config Winmgmt start= disabled %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel%  EQU  0 ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] Aborting... " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								sc config Winmgmt start= auto %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Stopping Winmgmt service
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service Winmgmt -force %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service Winmgmt -force %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service Winmgmt -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								sc query Winmgmt |  find /i " STOPPED "  %nul%  &&  ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) || ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Blue%  " Its recommended to select [Restart] option and then apply Fix WMI option again. " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								choice /C:21 /N /M " > [1] Restart  [2] Revert Back Changes : " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 1 ( sc config Winmgmt start= auto %nul% & goto  : at_back ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Restarting...
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								shutdown -t 5 -r
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Deleting WMI repository
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 13:37:39 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								rmdir  /s /q " %SysPath% \wbem\repository\ "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  " %SysPath% \wbem\repository\ "  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Enabling Winmgmt service
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								sc config Winmgmt start= auto %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel%  EQU  0 ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  [Successful]
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Failed] " 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : checkwmi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  error  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Checking WMI
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Green%  " [Working] " 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Registering .dll's and Compiling .mof's, .mfl's
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : registerobj  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo  Checking WMI
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : checkwmi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  error  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Red%  " [Not Responding] " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  Run [Dism RestoreHealth] and [SFC Scannow] options and make sure there are no errors.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %Green%  " [Working] " 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: registerobj 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :  https://eskonr.com/2012/01/how-to-fix-wmi-issues-automatically/ 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-11-15 21:03:20 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  Stop-Service Winmgmt -force %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 13:37:39 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								cd  /d %SysPath% \wbem\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								regsvr32 /s %SysPath% \scecli.dll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								regsvr32 /s %SysPath% \userenv.dll
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								mofcomp cimwin32.mof
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								mofcomp cimwin32.mfl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								mofcomp rsop.mof
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								mofcomp rsop.mfl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  %% s in  ( 'dir /b /s *.dll' )  do  regsvr32 /s %% s
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  %% s in  ( 'dir /b *.mof' )  do  mofcomp %% s
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  %% s in  ( 'dir /b *.mfl' )  do  mofcomp %% s
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								winmgmt /salvagerepository
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								winmgmt /resetrepository
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: checkwmi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  error = 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:18:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  " Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property CreationClassName "  %nul2%  |  find /i " computersystem "  %nul1% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %errorlevel%  NEQ  0 ( set  error = 1&  exit  /b) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								winmgmt /verifyrepository %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %errorlevel%  NEQ  0 ( set  error = 1&  exit  /b) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:18:57 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%psc%  " try { $null=([WMISEARCHER]'SELECT * FROM SoftwareLicensingService').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult } "  %nul% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								cmd /c exit /b %errorlevel% 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-05 16:53:02 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  " 0x %=ExitCode% "  |  findstr /i " 0x800410 0x800440 0x80131501 "  %nul1% 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %errorlevel%  EQU  0 set  error = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: at_back 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %line% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:38:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  terminal  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Yellow%  " Press [0] key to  %_exitmsg% ... " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:38:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								choice /c 0 /n
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Yellow%  " Press any key to  %_exitmsg% ... " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								pause  %nul1% 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 23:38:35 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								goto  : at_menu 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: compresslog 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  https://stackoverflow.com/a/46268232 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-17 21:11:47 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " ddf= " %SystemRoot% \Temp\%Random% %Random% %Random% %Random% " " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%nul%  del /q /f %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.New Cabinet> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set Cabinet=ON>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set CabinetFileCountThreshold=0;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set Compress=ON>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set CompressionType=LZX>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set CompressionLevel=7;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set CompressionMemory=21;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set FolderFileCountThreshold=0;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set FolderSizeThreshold=0;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set GenerateInf=OFF>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set InfFileName=nul>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set MaxCabinetSize=0;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set MaxDiskFileCount=0;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set MaxDiskSize=0;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set MaxErrors=1;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set RptFileName=nul>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo /.set UniqueFiles=ON>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " tokens=* delims= "  %% D in  ( 'dir /a:-D/b/s " %SystemRoot% \logs\ %1 "' )  do  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 echo /" %% ~fD "   /inf=no;>> %ddf% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:58:32 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								makecab /F %ddf%  /D DiskDirectory1=" "  /D CabinetNameTemplate=" !desktop! \ %2 _ %_time% .cab " 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								del  /q /f %ddf% 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: checkperms 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  This code checks if SPP has permission access to tokens folder and required registry keys. Incorrect permissions are often set by gaming spoofers. 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  permerror = 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  not  exist  " %tokenstore% \ "  set  " permerror=Error Found In Token Folder " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 04:59:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  ps32onArm  exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								" %tokenstore% +FullControl " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" HKLM:\SYSTEM\WPA+QueryValues, EnumerateSubKeys, WriteKey " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								" HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform+SetValue " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) do for /f "tokens=1,2 delims=+" %%A in (%%#) do if not defined permerror ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  " $acl = (Get-Acl ' %% A' | fl | Out-String); if (-not ($acl -match 'NT SERVICE\\sppsvc Allow   %% B') -or ($acl -match 'NT SERVICE\\sppsvc Deny')) {Exit 2} "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 2 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  " %% A " == " %tokenstore% "  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " permerror=Error Found In Token Folder " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " permerror=Error Found In SPP Registries " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 00:01:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								REM  https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  not  defined  permerror  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg query " HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion "  %nul%  &&  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " pol=HKU\S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Policies " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								reg query " !pol! "  %nul%  ||  reg add " !pol! "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  " $netServ = (New-Object Security.Principal.SecurityIdentifier('S-1-5-20')).Translate([Security.Principal.NTAccount]).Value; $aclString = Get-Acl 'Registry::!pol!' | Format-List | Out-String; if (-not ($aclString.Contains($netServ + ' Allow  FullControl') -or $aclString.Contains('NT SERVICE\sppsvc Allow  FullControl')) -or ($aclString.Contains('Deny'))) {Exit 3} "  %nul% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 3 set  " permerror=Error Found In S-1-5-20 SPP " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Fix SPP related registry and folder permissions 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: fixsppperms : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Fix perms for Token Folder
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if   ($env:permerror  - e q   ' E r r o r   F o u n d   I n   T o k e n   F o l d e r ' )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    New-Item -Path $env:tokenstore -ItemType Directory -Force
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $sddl = 'O:BAG:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICIIO;GR;;;BU)(A;;FR;;;BU)(A;OICI;FA;;;S-1-5-80-123231216-2592883651-3715271367-3753151631-4175906628)'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $AclObject = New-Object System.Security.AccessControl.DirectorySecurity
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $AclObject.SetSecurityDescriptorSddlForm($sddl)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Set-Acl -Path $env:tokenstore -AclObject $AclObject
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    exit 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Fix perms for SPP registries
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if   ($env:permerror  - e q   ' E r r o r   F o u n d   I n   S P P   R e g i s t r i e s ' )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $acl = Get-Acl 'HKLM:\SYSTEM\WPA'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $rule = New-Object System.Security.AccessControl.RegistryAccessRule ('NT Service\sppsvc', 'QueryValues, EnumerateSubKeys, WriteKey', 'ContainerInherit, ObjectInherit', 'None', 'Allow')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $acl.ResetAccessRule($rule)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $acl.SetAccessRule($rule)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Set-Acl -Path 'HKLM:\SYSTEM\WPA' -AclObject $acl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $acl = Get-Acl 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $rule = New-Object System.Security.AccessControl.RegistryAccessRule ('NT Service\sppsvc', 'SetValue', 'ContainerInherit, ObjectInherit', 'None', 'Allow')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $acl.ResetAccessRule($rule)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $acl.SetAccessRule($rule)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Set-Acl -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform' -AclObject $acl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    exit 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# Fix perms for SPP in HKU\S-1-5-20
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 00:01:04 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# https://learn.microsoft.com/en-us/office/troubleshoot/activation/license-issue-when-start-office-application
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if   ($env:permerror  - n e   ' E r r o r   F o u n d   I n   S - 1 - 5 - 2 0   S P P ' )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    exit 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if   (-not  ( T e s t - P a t h   ' R e g i s t r y : : H K U \ S - 1 - 5 - 2 0 \ S o f t w a r e \ M i c r o s o f t \ W i n d o w s   N T \ C u r r e n t V e r s i o n \ S o f t w a r e P r o t e c t i o n P l a t f o r m ' ) )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    exit 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# https://stackoverflow.com/a/35843420
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function Take-Permissions {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    param($rootKey, $key, [System.Security.Principal.SecurityIdentifier]$sid = 'S-1-5-32-545', $recurse = $true)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    switch -regex ($rootKey) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'HKCU| HKEY_CURRENT_USER' { $rootKey = 'CurrentUser' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'HKLM| HKEY_LOCAL_MACHINE' { $rootKey = 'LocalMachine' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'HKCR| HKEY_CLASSES_ROOT' { $rootKey = 'ClassesRoot' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'HKCC| HKEY_CURRENT_CONFIG' { $rootKey = 'CurrentConfig' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        'HKU| HKEY_USERS' { $rootKey = 'Users' }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ### Step 1 - escalate current process's privilege
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    # get SeTakeOwnership, SeBackup and SeRestore privileges before executes next lines, script needs Admin privilege
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $TypeBuilder = $ModuleBuilder.DefineType(0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $TypeBuilder.DefinePInvokeMethod('RtlAdjustPrivilege', 'ntdll.dll', 'Public, Static', 1, [int], @([int], [bool], [bool], [bool].MakeByRefType()), 1, 3) |  Out-Null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    9, 17, 18 |  ForEach-Object { $TypeBuilder.CreateType()::RtlAdjustPrivilege($_, $true, $false, [ref]$false) |  Out-Null }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    function Take-KeyPermissions {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        param($rootKey, $key, $sid, $recurse, $recurseLevel = 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ### Step 2 - get ownerships of key - it works only for current key
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $regKey = [Microsoft.Win32.Registry]::$rootKey.OpenSubKey($key, 'ReadWriteSubTree', 'TakeOwnership')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $acl = New-Object System.Security.AccessControl.RegistrySecurity
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $acl.SetOwner($sid)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $regKey.SetAccessControl($acl)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ### Step 3 - enable inheritance of permissions (not ownership) for current key from parent
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $acl.SetAccessRuleProtection($false, $false)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $regKey.SetAccessControl($acl)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ### Step 4 - only for top-level key, change permissions for current key and propagate it for subkeys
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        # to enable propagations for subkeys, it needs to execute Steps 2-3 for each subkey (Step 5)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if   ($recurseLevel  - e q   0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $regKey = $regKey.OpenSubKey('', 'ReadWriteSubTree', 'ChangePermissions')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $rule = New-Object System.Security.AccessControl.RegistryAccessRule($sid, 'FullControl', 'ContainerInherit', 'None', 'Allow')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $acl.ResetAccessRule($rule)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            $regKey.SetAccessControl($acl)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        ### Step 5 - recursively repeat steps 2-5 for subkeys
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if   ($recurse)  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            foreach ($subKey in $regKey.OpenSubKey('').GetSubKeyNames()) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                Take-KeyPermissions $rootKey ($key + '\' + $subKey) $sid $recurse ($recurseLevel + 1)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Take-KeyPermissions $rootKey $key $sid $recurse
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Take-Permissions " Users "  " S-1-5-20\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform "  " S-1-5-20 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: fixsppperms : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Install License files using Powershell/WMI instead of slmgr.vbs 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: xrm : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function InstallLicenseFile($Lsc) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $null = $sls.InstallLicense([IO.File]::ReadAllText($Lsc))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } catch {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        $host.SetShouldExit($_.Exception.HResult)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function InstallLicenseArr($Str) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $a = $Str -split ';'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    ForEach ($x in $a) {InstallLicenseFile " $x " }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function InstallLicenseDir($Loc) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									Get-ChildItem $Loc -Recurse -Filter *.xrm-ms |  ForEach-Object {InstallLicenseFile $_.FullName}
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								function ReinstallLicenses() {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									$Paths = @(" $env:SysPath\oem " , " $env:SysPath\licensing " , " $env:SysPath\spp\tokens " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									foreach ($Path in $Paths) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if   (Test-Path  $ P a t h )   {   I n s t a l l L i c e n s e D i r   " $ P a t h "   } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-08-17 22:14:07 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: xrm : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: scandat 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  token = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-19 13:37:39 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%SysPath% \spp\store_test\2.0\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%SysPath% \spp\store\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%SysPath% \spp\store\2.0\
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								%Systemdrive% \Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareProtectionPlatform\
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								%Systemdrive% \Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\SoftwareLicensing\
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) do ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %1 == check ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  %% #tokens.dat set  token = %% #tokens.dat
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %1 == delete ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  %% # ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%nul%  dir /a-d /s " %% #*.dat "  &&  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								attrib -r -s -h " %% #*.dat "  /S
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								del  /S /F /Q " %% #*.dat " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: scandatospp 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  token = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  %% # in  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%ProgramData% \Microsoft\OfficeSoftwareProtectionPlatform\
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) do ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %1 == check ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  %% #tokens.dat set  token = %% #tokens.dat
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %1 == delete ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  exist  %% # ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%nul%  dir /a-d /s " %% #*.dat "  &&  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								attrib -r -s -h " %% #*.dat "  /S
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								del  /S /F /Q " %% #*.dat " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: regownstart 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  " $f=[io.file]::ReadAllText('!_batp!') -split ':regown\:.*';iex ($f[1]); " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  Below code takes ownership of a volatile registry key and deletes it 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :  HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: regown : 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-16 18:11:04 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$TypeBuilder = $ModuleBuilder.DefineType(0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$TypeBuilder.DefinePInvokeMethod('RtlAdjustPrivilege', 'ntdll.dll', 'Public, Static', 1, [int], @([int], [bool], [bool], [bool].MakeByRefType()), 1, 3) |  Out-Null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$TypeBuilder.CreateType()::RtlAdjustPrivilege(9, $true, $false, [ref]$false) |  Out-Null
							 
						 
					
						
							
								
									
										
										
										
											2022-11-07 20:33:01 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$SID = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$IDN = ($SID.Translate([System.Security.Principal.NTAccount])).Value
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$Admin = New-Object System.Security.Principal.NTAccount($IDN)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$path = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ClipSVC\Volatile\PersistedSystemState'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$key = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey($path, 'ReadWriteSubTree', 'takeownership')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$acl = $key.GetAccessControl()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$acl.SetOwner($Admin)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$key.SetAccessControl($acl)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$rule = New-Object System.Security.AccessControl.RegistryAccessRule($Admin," FullControl " ," Allow " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$acl.SetAccessRule($rule)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								$key.SetAccessControl($acl)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: regown : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: dk_color 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %_NCS%  EQU  1 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %esc% [%~1 %~2 %esc% [0m
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else if exist %ps% ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  write-host -back '%1 ' -fore '%2 ' '%3 '
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else if not exist %ps% ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %~3 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: dk_color2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %_NCS%  EQU  1 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %esc% [%~1 %~2 %esc% [%~3 %~4 %esc% [0m
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else if exist %ps% ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								%psc%  write-host -back '%1 ' -fore '%2 ' '%3 ' -NoNewline; write-host -back '%4 ' -fore '%5 ' '%6 '
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else if not exist %ps% ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo  %~3  %~6 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: dk_done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								echo :
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  %_unattended% == 1 timeout /t 2 &  exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  defined  fixes  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-07 23:51:08 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %White%  " Follow ALL the ABOVE blue lines.    " 
							 
						 
					
						
							
								
									
										
										
										
											2024-09-27 02:34:25 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color2  %Blue%  " Press [1] to Open Support Webpage  "  %Gray%  "  Press [0] to Ignore " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								choice /C:10 /N
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 14:23:15 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 2 exit  /b
							 
						 
					
						
							
								
									
										
										
										
											2025-05-18 06:39:25 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  !errorlevel! == 1 ( start  https://git.activated.win/massg%-% rave/Micr%-% osoft-Act%-% ivation-Scripts &  start  https://github.com/massgra%-% vel/Micro%-% soft-Acti%-% vation-Scripts &  for  %% # in  ( %fixes% )  do  ( start  %% #) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  defined  terminal  ( 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-20 17:15:06 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Yellow%  " Press [0] key to  %_exitmsg% ... " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								choice /c 0 /n
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								call  : dk_color  %_Yellow%  " Press any key to  %_exitmsg% ... " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								pause  %nul1% 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :  Set variables 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: dk_setvar 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  ps = %SysPath% \WindowsPowerShell\v1.0\powershell.exe
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  psc = %ps%  -nop -c
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  winbuild = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /f  " tokens=6 delims=[].  "  %% G in  ( 'ver' )  do  set  winbuild = %% G
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 14:05:53 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  _slexe = sppsvc.exe&  set  _slser = sppsvc
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  LEQ  6300 ( set  _slexe = SLsvc.exe&  set  _slser = SLsvc) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  7600 if  exist  " %SysPath% \SLsvc.exe "  ( set  _slexe = SLsvc.exe&  set  _slser = SLsvc) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %_slexe% == SLsvc.exe set  _vis = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  _NCS = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  LSS  10586 set  _NCS = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %winbuild%  GEQ  10586 reg query " HKCU\Console "  /v ForceV2 %nul2%  |  find /i " 0x0 "  %nul1%  &&  ( set  _NCS = 0) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-10-30 04:59:31 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								echo  " %PROCESSOR_ARCHITECTURE%   %PROCESSOR_ARCHITEW6432% "  |  find /i " ARM64 "  %nul1%  &&  ( if  %winbuild%  LSS  21277 set  ps32onArm = 1) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								if  %_NCS%  EQU  1 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for  /F  %% a in  ( 'echo prompt $E ^| cmd' )  do  set  " esc= %% a " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set      " Red= " 41;97m" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set     " Gray= " 100;97m" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set    " Green= " 42;97m" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set     " Blue= " 44;97m" " 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-07 23:51:08 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set    " White= " 107;91m" " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set     " _Red= " 40;91m" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set   " _White= " 40;37m" " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set   " _Green= " 40;92m" " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								set  " _Yellow= " 40;93m" " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set      " Red= " Red"   " white" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set     " Gray= " Darkgray"   " white" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set    " Green= " DarkGreen"   " white" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set     " Blue= " Blue"   " white" " 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-08 14:40:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set    " White= " White"   " Red" " 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set     " _Red= " Black"   " Red" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set   " _White= " Black"   " Gray" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set   " _Green= " Black"   " Green" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _Yellow= " Black"   " Yellow" " 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-16 20:11:42 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								set  " nceline=echo: &echo ==== ERROR ==== &echo: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " eline=echo: &call :dk_color  %Red%   " ==== ERROR ===="  &echo: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								if  %~z0  GEQ  200000 ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _exitmsg=Go back " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _fixmsg=Go back to Main Menu, select Troubleshoot and run Fix Licensing option. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) else ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _exitmsg=Exit " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								set  " _fixmsg=In MAS folder, run Troubleshoot script and select Fix Licensing option. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-25 18:03:00 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								exit  /b
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 13:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								: :======================================================================================================================================== 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								: : Leave empty line below