aboutsummaryrefslogtreecommitdiff
path: root/MAS/Separate-Files-Version/Troubleshoot.cmd
diff options
context:
space:
mode:
authorWindowsAddict <windowsaddict@protonmail.com>2023-11-16 02:33:20 +0530
committerWindowsAddict <windowsaddict@protonmail.com>2023-11-16 02:33:20 +0530
commit066b135cfdd8716add8a159ce183011def0f888f (patch)
tree23daec2cbcca6eb1946ef59d8e8e61127a06f6f2 /MAS/Separate-Files-Version/Troubleshoot.cmd
parent64e006703cdb21608150a4dce173294d69fb6036 (diff)
2.52.5
Diffstat (limited to 'MAS/Separate-Files-Version/Troubleshoot.cmd')
-rw-r--r--MAS/Separate-Files-Version/Troubleshoot.cmd138
1 files changed, 77 insertions, 61 deletions
diff --git a/MAS/Separate-Files-Version/Troubleshoot.cmd b/MAS/Separate-Files-Version/Troubleshoot.cmd
index 194c1a7..6f83f30 100644
--- a/MAS/Separate-Files-Version/Troubleshoot.cmd
+++ b/MAS/Separate-Files-Version/Troubleshoot.cmd
@@ -1,9 +1,9 @@
1@set masver=2.4 1@set masver=2.5
2@setlocal DisableDelayedExpansion 2@setlocal DisableDelayedExpansion
3@echo off 3@echo off
4 4
5 5
6:: 6
7::============================================================================ 7::============================================================================
8:: 8::
9:: This script is a part of 'Microsoft_Activation_Scripts' (MAS) project. 9:: This script is a part of 'Microsoft_Activation_Scripts' (MAS) project.
@@ -208,7 +208,7 @@ echo ________________________________________________
208echo You are running outdated version MAS %masver% 208echo You are running outdated version MAS %masver%
209echo ________________________________________________ 209echo ________________________________________________
210echo: 210echo:
211echo [1] Download Latest MAS 211echo [1] Get Latest MAS
212echo [0] Continue Anyway 212echo [0] Continue Anyway
213echo: 213echo:
214call :_color %_Green% "Enter a menu option in the Keyboard [1,0] :" 214call :_color %_Green% "Enter a menu option in the Keyboard [1,0] :"
@@ -323,7 +323,7 @@ if %errorlevel%==1 goto at_menu
323 323
324cls 324cls
325mode 110, 30 325mode 110, 30
326call :_stopservice TrustedInstaller 326%psc% Stop-Service TrustedInstaller -force %nul%
327 327
328set _time= 328set _time=
329for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a 329for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a
@@ -332,7 +332,7 @@ echo Applying the command,
332echo dism /english /online /cleanup-image /restorehealth 332echo dism /english /online /cleanup-image /restorehealth
333dism /english /online /cleanup-image /restorehealth 333dism /english /online /cleanup-image /restorehealth
334 334
335call :_stopservice TrustedInstaller 335%psc% Stop-Service TrustedInstaller -force %nul%
336 336
337if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% 337if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul%
338 338
@@ -375,7 +375,7 @@ choice /C:09 /N /M "> [9] Continue [0] Go back : "
375if %errorlevel%==1 goto at_menu 375if %errorlevel%==1 goto at_menu
376 376
377cls 377cls
378call :_stopservice TrustedInstaller 378%psc% Stop-Service TrustedInstaller -force %nul%
379 379
380set _time= 380set _time=
381for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a 381for /f %%a in ('%psc% "Get-Date -format HH_mm_ss"') do set _time=%%a
@@ -384,7 +384,7 @@ echo Applying the command,
384echo sfc /scannow 384echo sfc /scannow
385sfc /scannow 385sfc /scannow
386 386
387call :_stopservice TrustedInstaller 387%psc% Stop-Service TrustedInstaller -force %nul%
388 388
389if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul% 389if not exist "!desktop!\AT_Logs\" md "!desktop!\AT_Logs\" %nul%
390 390
@@ -455,7 +455,7 @@ goto :cleanvnext
455) 455)
456 456
457echo Stopping ClipSVC service... 457echo Stopping ClipSVC service...
458call :_stopservice ClipSVC 458%psc% Stop-Service ClipSVC -force %nul%
459timeout /t 2 %nul% 459timeout /t 2 %nul%
460 460
461echo: 461echo:
@@ -505,7 +505,7 @@ call :_color %Red% "[Failed]"
505echo [Successful] 505echo [Successful]
506) 506)
507 507
508call :_stopservice ClipSVC 508%psc% Stop-Service ClipSVC -force %nul%
509 509
510:: Rebuild ClipSVC folder to fix permission issues 510:: Rebuild ClipSVC folder to fix permission issues
511 511
@@ -522,7 +522,7 @@ echo [Successful]
522 522
523echo: 523echo:
524echo Rebuilding Folder %ProgramData%\Microsoft\Windows\ClipSVC\ 524echo Rebuilding Folder %ProgramData%\Microsoft\Windows\ClipSVC\
525net start ClipSVC /y %nul% 525%psc% Start-Service ClipSVC %nul%
526timeout /t 3 %nul% 526timeout /t 3 %nul%
527if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" timeout /t 5 %nul% 527if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" timeout /t 5 %nul%
528if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" ( 528if not exist "%ProgramData%\Microsoft\Windows\ClipSVC\" (
@@ -534,7 +534,7 @@ echo [Successful]
534 534
535echo: 535echo:
536echo Restarting [wlidsvc LicenseManager] services... 536echo Restarting [wlidsvc LicenseManager] services...
537for %%# in (wlidsvc LicenseManager) do (net stop %%# /y %nul% & net start %%# /y %nul%) 537for %%# in (wlidsvc LicenseManager) do (%psc% Restart-Service %%# %nul%)
538 538
539::======================================================================================================================================== 539::========================================================================================================================================
540 540
@@ -580,7 +580,7 @@ echo Not Found - !_Local!\Microsoft\Office\Licenses\
580 580
581 581
582echo: 582echo:
583for /f "tokens=* delims=" %%a in ('%psc% "$userSIDs = Get-WmiObject -Class Win32_UserAccount | ForEach-Object {write-host $_.SID}" %nul6%') do (if defined _sid (set "_sid=!_sid! HKU\%%a") else (set "_sid=HKU\%%a")) 583for /f "tokens=* delims=" %%a in ('%psc% "Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' | ForEach-Object { Split-Path -Path $_.PSPath -Leaf }" %nul6%') do (if defined _sid (set "_sid=!_sid! HKU\%%a") else (set "_sid=HKU\%%a"))
584 584
585set regfound= 585set regfound=
586for %%# in (HKCU !_sid!) do ( 586for %%# in (HKCU !_sid!) do (
@@ -619,19 +619,13 @@ call :_color %Red% "tokens.dat file not found."
619echo tokens.dat file: [%token%] 619echo tokens.dat file: [%token%]
620) 620)
621 621
622if %winbuild% GEQ 14393 (
623set wpaerror=
624set /a count=0
625for /f %%a in ('reg query "HKLM\SYSTEM\WPA" %nul6%') do set /a count+=1
626for /L %%# in (1,1,!count!) do (
627reg query "HKLM\SYSTEM\WPA\8DEC0AF1-0341-4b93-85CD-72606C2DF94C-7P-%%#" /ve /t REG_BINARY %nul% || set wpaerror=1
628)
629
630if defined wpaerror (
631echo: 622echo:
632echo Checking WPA Registry Keys... 623set wpainfo=
633call :_color %Red% "[Error Found] [Registry Count - !count!]" 624for /f "delims=" %%a in ('%psc% "$f=[io.file]::ReadAllText('!_batp!') -split ':wpatest\:.*';iex ($f[1]);" %nul6%') do (set wpainfo=%%a)
634) 625echo "%wpainfo%" | find /i "Error Found" %nul% && (
626call :_color %Red% "WPA Registry Error: %wpainfo%"
627) || (
628echo WPA Registry Count: %wpainfo%
635) 629)
636 630
637set tokenstore= 631set tokenstore=
@@ -679,7 +673,7 @@ echo [No Error Found]
679 673
680echo: 674echo:
681echo Stopping sppsvc service... 675echo Stopping sppsvc service...
682call :_stopservice sppsvc 676%psc% Stop-Service sppsvc -force %nul%
683 677
684echo: 678echo:
685call :scandat delete 679call :scandat delete
@@ -736,7 +730,7 @@ echo tokens.dat file: [%token%]
736 730
737echo: 731echo:
738echo Stopping osppsvc service... 732echo Stopping osppsvc service...
739call :_stopservice osppsvc 733%psc% Stop-Service osppsvc -force %nul%
740 734
741echo: 735echo:
742call :scandatospp delete 736call :scandatospp delete
@@ -750,11 +744,11 @@ echo:
750 744
751echo: 745echo:
752echo Starting osppsvc service to generate tokens.dat 746echo Starting osppsvc service to generate tokens.dat
753call :_startservice osppsvc 747%psc% Start-Service osppsvc %nul%
754call :scandatospp check 748call :scandatospp check
755if not defined token ( 749if not defined token (
756call :_stopservice osppsvc 750%psc% Stop-Service osppsvc -force %nul%
757call :_startservice osppsvc 751%psc% Start-Service osppsvc %nul%
758timeout /t 3 %nul% 752timeout /t 3 %nul%
759) 753)
760 754
@@ -801,18 +795,20 @@ for %%A in (msi14 msi15 msi16 c2r14 c2r15 c2r16) do (set %%A_%%#=&set %%Arepair%
801set _68=HKLM\SOFTWARE\Microsoft\Office 795set _68=HKLM\SOFTWARE\Microsoft\Office
802set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office 796set _86=HKLM\SOFTWARE\Wow6432Node\Microsoft\Office
803 797
804%nul% reg query %_68%\14.0\Common\InstallRoot /v Path && (set "msi14_68=Office 14.0 MSI x86/x64" & set "msi14repair68=%systemdrive%\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\Setup.exe") 798reg query %_68%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=")
805%nul% reg query %_86%\14.0\Common\InstallRoot /v Path && (set "msi14_86=Office 14.0 MSI x86" & set "msi14repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\Office Setup Controller\Setup.exe") 799reg query %_86%\14.0\CVH /f Click2run /k %nul% && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=")
806%nul% reg query %_68%\15.0\Common\InstallRoot /v Path && (set "msi15_68=Office 15.0 MSI x86/x64" & set "msi15repair68=%systemdrive%\Program Files\Common Files\microsoft shared\OFFICE15\Office Setup Controller\Setup.exe") 800
807%nul% reg query %_86%\15.0\Common\InstallRoot /v Path && (set "msi15_86=Office 15.0 MSI x86" & set "msi15repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE15\Office Setup Controller\Setup.exe") 801for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_86=Office 14.0 MSI x86" & set "msi14repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE14\Office Setup Controller\Setup.exe")
808%nul% reg query %_68%\16.0\Common\InstallRoot /v Path && (set "msi16_68=Office 16.0 MSI x86/x64" & set "msi16repair68=%systemdrive%\Program Files\Common Files\Microsoft Shared\OFFICE16\Office Setup Controller\Setup.exe") 802for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\14.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi14_68=Office 14.0 MSI x86/x64" & set "msi14repair68=%systemdrive%\Program Files\Common Files\microsoft shared\OFFICE14\Office Setup Controller\Setup.exe")
809%nul% reg query %_86%\16.0\Common\InstallRoot /v Path && (set "msi16_86=Office 16.0 MSI x86" & set "msi16repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\Office Setup Controller\Setup.exe") 803for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_86=Office 15.0 MSI x86" & set "msi15repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE15\Office Setup Controller\Setup.exe")
810%nul% reg query %_68%\14.0\CVH /f Click2run /k && (set "c2r14_68=Office 14.0 C2R x86/x64" & set "c2r14repair68=") 804for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\15.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi15_68=Office 15.0 MSI x86/x64" & set "msi15repair68=%systemdrive%\Program Files\Common Files\microsoft shared\OFFICE15\Office Setup Controller\Setup.exe")
811%nul% reg query %_86%\14.0\CVH /f Click2run /k && (set "c2r14_86=Office 14.0 C2R x86" & set "c2r14repair86=") 805for /f "skip=2 tokens=2*" %%a in ('"reg query %_86%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_86=Office 16.0 MSI x86" & set "msi16repair86=%systemdrive%\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\Office Setup Controller\Setup.exe")
812%nul% reg query %_68%\15.0\ClickToRun /v InstallPath && (set "c2r15_68=Office 15.0 C2R x86/x64" & set "c2r15repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe") 806for /f "skip=2 tokens=2*" %%a in ('"reg query %_68%\16.0\Common\InstallRoot /v Path" %nul6%') do if exist "%%b\EntityPicker.dll" (set "msi16_68=Office 16.0 MSI x86/x64" & set "msi16repair68=%systemdrive%\Program Files\Common Files\Microsoft Shared\OFFICE16\Office Setup Controller\Setup.exe")
813%nul% reg query %_86%\15.0\ClickToRun /v InstallPath && (set "c2r15_86=Office 15.0 C2R x86" & set "c2r15repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe") 807
814%nul% reg query %_68%\ClickToRun /v InstallPath && (set "c2r16_68=Office 16.0 C2R x86/x64" & set "c2r16repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe") 808for /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" & set "c2r15repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe")
815%nul% reg query %_86%\ClickToRun /v InstallPath && (set "c2r16_86=Office 16.0 C2R x86" & set "c2r16repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe") 809for /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" & set "c2r15repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\integratedoffice.exe")
810for /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" & set "c2r16repair86=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe")
811for /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" & set "c2r16repair68=%systemdrive%\Program Files\Microsoft Office 15\Client%arch%\OfficeClickToRun.exe")
816 812
817set uwp16= 813set uwp16=
818if %winbuild% GEQ 10240 ( 814if %winbuild% GEQ 10240 (
@@ -938,7 +934,7 @@ call :checkwmi
938:: Apply basic fix first and check 934:: Apply basic fix first and check
939 935
940if defined error ( 936if defined error (
941call :_stopservice Winmgmt 937%psc% Stop-Service Winmgmt -force %nul%
942winmgmt /salvagerepository %nul% 938winmgmt /salvagerepository %nul%
943call :checkwmi 939call :checkwmi
944) 940)
@@ -976,9 +972,9 @@ goto :at_back
976 972
977echo: 973echo:
978echo Stopping Winmgmt service 974echo Stopping Winmgmt service
979call :_stopservice Winmgmt 975%psc% Stop-Service Winmgmt -force %nul%
980call :_stopservice Winmgmt 976%psc% Stop-Service Winmgmt -force %nul%
981call :_stopservice Winmgmt 977%psc% Stop-Service Winmgmt -force %nul%
982sc query Winmgmt | find /i "STOPPED" %nul% && ( 978sc query Winmgmt | find /i "STOPPED" %nul% && (
983echo [Successful] 979echo [Successful]
984) || ( 980) || (
@@ -1042,7 +1038,7 @@ goto :at_back
1042 1038
1043:: https://eskonr.com/2012/01/how-to-fix-wmi-issues-automatically/ 1039:: https://eskonr.com/2012/01/how-to-fix-wmi-issues-automatically/
1044 1040
1045call :_stopservice Winmgmt 1041%psc% Stop-Service Winmgmt -force %nul%
1046cd /d %systemroot%\system32\wbem\ 1042cd /d %systemroot%\system32\wbem\
1047regsvr32 /s %systemroot%\system32\scecli.dll 1043regsvr32 /s %systemroot%\system32\scecli.dll
1048regsvr32 /s %systemroot%\system32\userenv.dll 1044regsvr32 /s %systemroot%\system32\userenv.dll
@@ -1128,21 +1124,41 @@ exit /b
1128 1124
1129::======================================================================================================================================== 1125::========================================================================================================================================
1130 1126
1131:_stopservice 1127:: This code checks for invalid registry keys in HKLM\SYSTEM\WPA. This issue may appear even on healthy systems
1132 1128
1133for %%# in (%1) do ( 1129:wpatest:
1134sc query %%# | find /i "STOPPED" %nul% || net stop %%# /y %nul% 1130$wpaKey = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 'Registry64').OpenSubKey("SYSTEM\\WPA")
1135sc query %%# | find /i "STOPPED" %nul% || sc stop %%# %nul% 1131$count = $wpaKey.SubKeyCount
1136) 1132
1137exit /b 1133$osVersion = [System.Environment]::OSVersion.Version
1138 1134$minBuildNumber = 14393
1139:_startservice 1135
1140 1136if ($osVersion.Build -ge $minBuildNumber) {
1141for %%# in (%1) do ( 1137 $subkeyHashTable = @{}
1142sc query %%# | find /i "RUNNING" %nul% || net start %%# /y %nul% 1138 foreach ($subkeyName in $wpaKey.GetSubKeyNames()) {
1143sc query %%# | find /i "RUNNING" %nul% || sc start %%# %nul% 1139 $keyNumber = $subkeyName -replace '.*-', ''
1144) 1140 $subkeyHashTable[$keyNumber] = $true
1145exit /b 1141 }
1142 for ($i=1; $i -le $count; $i++) {
1143 if (-not $subkeyHashTable.ContainsKey("$i")) {
1144 Write-Host "Total Keys $count. Error Found- $i key does not exist"
1145 $wpaKey.Close()
1146 exit
1147 }
1148 }
1149}
1150$wpaKey.GetSubKeyNames() | ForEach-Object {
1151 $subkey = $wpaKey.OpenSubKey($_)
1152 $p = $subkey.GetValueNames()
1153 if (($p | Where-Object { $subkey.GetValueKind($_) -eq [Microsoft.Win32.RegistryValueKind]::Binary }).Count -eq 0) {
1154 Write-Host "Total Keys $count. Error Found- Binary Data is corrupt"
1155 $wpaKey.Close()
1156 exit
1157 }
1158}
1159$count
1160$wpaKey.Close()
1161:wpatest:
1146 1162
1147::======================================================================================================================================== 1163::========================================================================================================================================
1148 1164