dism.exe isn't running.
Posted: 30 Nov 2023 01:21
This code isn't working:
The above code is from the cmd window.
dism.exe isn't running.
The original script follows:
Does anyone have any idea why the dism.exe won't run?
Code: Select all
C:\>If "10.0" == 10.0 (
Echo Running Window 10
If "C:" == C: (dism.exe /Online /Cleanup-Image /RestoreHealth /ScratchDir:C:\Temp 1>>"G:\Dnload\SFCResults.txt" )
IF NOT "C:" == C: (dism.exe /image:C:\ /cleanup-image /RestoreHealth /ScratchDir:C:\Temp 1>>"G:\Dnload\SFCResults.txt" )
Start notepad "G:\Dnload\sfcResults.txt"
)
dism.exe isn't running.
The original script follows:
Code: Select all
@Echo On
:: Run this from a USB or CD in Windows Recovery Environment Windows Repair cmd prompt
:: Drive = the drive letter of where windows is located when running in Winddow Repair
setlocal EnableDelayedExpansion
set /p Drive=Please enter drive letter. Example C
for %%j in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
set "Drive=!Drive:%%j=%%j!"
)
set "colin=:"
set "Drive=%Drive%%colin%"
echo %Drive%
%Drive%
CD\
If not exist Temp md Temp
Echo wmic os get caption
echo %PROCESSOR_ARCHITECTURE%
for /f "tokens=2 delims=:" %%a in (' wmic os get caption ^| find "OS Name"') do set OS_Name=%%a
for /f "tokens=* delims= " %%a in ("%OS_Name%") do set OS_Name=%%a
for /f "tokens=3 delims= " %%a in ("%OS_Name%") do set OS_Name=%%a
Echo: OS_Name = %os_name%
if "%os_name%"=="XP" set "version=XP"
if "%os_name%"=="7" "set version=7"
for /f "tokens=2 delims=," %%i in ('wmic os get caption^,version /format:csv') do set os=%%i
echo %os%|find " 10 ">nul &&echo Hello I'm Windows 10||echo I am another os
setlocal
for /f "tokens=2 delims=[]" %%i in ('ver') do set VERSION=%%i
for /f "tokens=2-3 delims=. " %%i in ("%VERSION%") do set VERSION=%%i.%%j
if "%VERSION%" == "5.00" echo Windows 2000
if "%VERSION%" == "5.0" echo Windows 2000
if "%VERSION%" == "5.1" echo Windows XP
if "%VERSION%" == "5.2" echo Windows Server 2003
if "%VERSION%" == "6.0" echo Windows Vista
if "%VERSION%" == "6.1" echo Windows 7
if "%VERSION%" == "6.2" echo Windows 8
if "%VERSION%" == "6.3" echo Windows 8.1
if "%VERSION%" == "6.4" echo Windows 10
if "%VERSION%" == "10.0" echo Windows 10
echo %VERSION%
If "%version%"==10.0 (
Echo Running Window 10
PAUSE
If "%Drive%"==C: (
dism.exe /Online /Cleanup-Image /RestoreHealth /ScratchDir:%Drive%\Temp >> "%~dp0SFCResults.txt"
)
IF NOT "%Drive%"==C: (
dism.exe /image:%Drive%\ /cleanup-image /RestoreHealth /ScratchDir:%Drive%\Temp >> "%~dp0SFCResults.txt"
)
Start notepad "%~dp0sfcResults.txt"
)
endlocal
:Skip
icacls %Drive%\Windows\logs\cbs\cbs.log /grant Gary:F
del /q C:\Windows\logs\cbs\cbs.log
Set i=1
:again
If exist "%~dp0sfcdetails_%i%.txt" (
set /A i=i+1
goto again
Set x=%i%
ren "%~dp0sfcdetails.txt" "sfcdetails_%%x%%.txt")
If %Drive%==C: (
SFC /scannow >"%~dp0sfcresults.txt"
)
IF NOT %Drive%==C: (
SFC /SCANNOW /OFFBOOTDIR=C:\ /OFFWINDIR=%Drive%\Windows >"%~dp0sfcresults.txt"
)
::findstr /c:"[SR]" %Drive%\Windows\logs\cbs\cbs.log >"%~dp0sfcdetails.txt"
::notepad "%~dp0sfcdetails.txt"
type C:\Windows\logs\cbs\cbs.log | find /i "[SR]" >> "%~dp0sfcdetails.txt" && notepad "%~dp0sfcdetails.txt"
rem optional command to shut down & restart pc after running. this may be needed if
rem sfc replaces some critical files. uncomment (remove the 'rem') to activate.
copy %windir%\Logs\CBS\cbs.log "%~dp0cbs.txt"
cmd /k