Page 1 of 1

dism.exe isn't running.

Posted: 30 Nov 2023 01:21
by Docfxit
This code isn't working:

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"
)
The above code is from the cmd window.
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
Does anyone have any idea why the dism.exe won't run?

Re: dism.exe isn't running.

Posted: 30 Nov 2023 01:26
by miskox

Code: Select all

If "%Drive%"==C:
should be

Code: Select all

If "%Drive%"=="C:"
Maybe you could add /I to the IF statement.

Same goes for other IF statements.

Saso

Re: dism.exe isn't running.

Posted: 30 Nov 2023 03:28
by Batcher
You need double quotation marks for both of LeftStr and RightStr.

Code: Select all

if "LeftStr" == "RightStr" (
    echo Yes
) else (
    echo No
)
So, update your code.

Code: Select all

if "%version%" == "10.0" (
    echo Running Window 10
    pause
    if "%Drive%" == "C:" (
        dism.exe /Online /Cleanup-Image /RestoreHealth /ScratchDir:%Drive%\Temp >> "%~dp0SFCResults.txt"
    ) else (
        dism.exe /image:%Drive%\ /cleanup-image /RestoreHealth /ScratchDir:%Drive%\Temp >> "%~dp0SFCResults.txt"
    )
    start notepad "%~dp0sfcResults.txt"
)

Re: dism.exe isn't running.

Posted: 30 Nov 2023 17:35
by Docfxit
Thank you both for the reply...

That solved that problem.

I have run into another problem that I can't figure out.

Code: Select all

C:\>C:\Batch\SetACL.exe -on "C:\Temp" -ot folder -actn ace "n:Win10BootRepair\Gary;p:full"
ERROR in command line: Invalid object type specified: folder!

Re: dism.exe isn't running.

Posted: 30 Nov 2023 19:18
by Batcher
-ot folder ---> -ot file

https://helgeklein.com/setacl/documenta ... etacl-exe/
Type of object:
  • file Directory/file
    reg Registry key
    srv Service
    prn Printer
    shr Network share
    wmi WMI object

Re: dism.exe isn't running.

Posted: 05 Dec 2023 12:26
by Squashman
Docfxit wrote:
30 Nov 2023 17:35
Thank you both for the reply...

That solved that problem.

I have run into another problem that I can't figure out.

Code: Select all

C:\>C:\Batch\SetACL.exe -on "C:\Temp" -ot folder -actn ace "n:Win10BootRepair\Gary;p:full"
ERROR in command line: Invalid object type specified: folder!
Like when you posted this same exact problem in this thread.

Re: dism.exe isn't running.

Posted: 05 Dec 2023 12:38
by Squashman
And you have been warned about not using quotes with IF comparisons at least twice previously.
viewtopic.php?f=3&t=10778&p=68385#p68387
viewtopic.php?f=3&t=9397&p=60988#p60991