From fb113c7c243190b267722d4a5fca48bc0a7a40e4 Mon Sep 17 00:00:00 2001 From: WindowsAddict Date: Sun, 18 Aug 2024 04:48:57 +0530 Subject: [PATCH] Replace wmic.exe with Powershell in fix wmi --- MAS/Separate-Files-Version/Troubleshoot.cmd | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/MAS/Separate-Files-Version/Troubleshoot.cmd b/MAS/Separate-Files-Version/Troubleshoot.cmd index 415f204..e35d102 100644 --- a/MAS/Separate-Files-Version/Troubleshoot.cmd +++ b/MAS/Separate-Files-Version/Troubleshoot.cmd @@ -892,12 +892,6 @@ echo WMI rebuild is not recommended on Windows Server. Aborting... goto :at_back ) -for %%# in (wmic.exe) do @if "%%~$PATH:#"=="" ( -%eline% -echo wmic.exe file is not found in the system. Aborting... -goto :at_back -) - echo: echo Checking WMI call :checkwmi @@ -1030,12 +1024,12 @@ exit /b :: https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-error-constants set error= -wmic path Win32_ComputerSystem get CreationClassName /value %nul2% | find /i "computersystem" %nul1% +%psc% "Get-WmiObject -Class Win32_ComputerSystem | Select-Object -Property CreationClassName" %nul2% | find /i "computersystem" %nul1% if %errorlevel% NEQ 0 (set error=1& exit /b) winmgmt /verifyrepository %nul% if %errorlevel% NEQ 0 (set error=1& exit /b) -cscript //nologo %windir%\system32\slmgr.vbs /dlv %nul% +%psc% "try { $null=([WMISEARCHER]'SELECT * FROM SoftwareLicensingService').Get().Version; exit 0 } catch { exit $_.Exception.InnerException.HResult }" %nul% cmd /c exit /b %errorlevel% echo "0x%=ExitCode%" | findstr /i "0x800410 0x800440" %nul1% if %errorlevel% EQU 0 set error=1