[Batch] My own general inability

Discussion in 'Scripting' started by Humphrey, Apr 7, 2014.

  1. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #1 Humphrey, Apr 7, 2014
    Last edited by a moderator: Apr 20, 2017
    ~ED~

    Think I will just make this my help me solve this problem thread.

    ----


    Something is wrong with this.

    SOLVED:
    It is meant to:
    Set DISM location, check if it exist and if so make folders and goto :getadmin.

    OR

    Set DISM location, check if it exist and if NOT- ask for its location, check if it exist reset DISM location to where it was supplied by user then goto get admin.

    For some reason it jumps from where the user sets the location to another place in the batch file.

    Code:
    :DISMCheck
    :: Checks for DISM
    SET DISM=C:\Windows\System32\DISM.EXE
    
    IF EXIST !DISM! (
        :: Creates WorkDir and subfolders.
        IF NOT EXIST "WorkDir" MD WorkDir & MD WorkDir\Mount & MD WorkDir\Images & MD WorkDir\ISO
        GOTO :GetAdmin
    ) ELSE (
    :: DISM wasn't found.
    ECHO.
    ECHO. Couldn't locate DISM.exe at C:\Windows\System32\Dism.exe
    ECHO.
    SET /P altdism=Drag and drop Dism.exe here:
    IF EXIST "!altdism!" (
        DISM=!altdism! 
        PAUSE
        GOTO :GetAdmin
    ) ELSE (
    CLS&GOTO :DISMCheck
    )
    )
    

    :ill:
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    #2 Compo, Apr 7, 2014
    Last edited by a moderator: Apr 20, 2017
    See Code in Red
     
  3. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    :fear2::doh:


    It was so simple.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #4 Humphrey, Apr 8, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    When running DISM /Get-CurrentEdition you get something like the following.

    Code:
    C:\Windows\system32>DISM /image:%mountdir% /Get-CurrentEdition
    
    Deployment Image Servicing and Management tool
    Version: 6.1.7600.16385
    
    
    Current Edition: Home Basic
    
    The command completed successfully. 
    
    C:\Windows\system32>
    
    I need to capture the "Home Basic" (and any other edition that may appear here mounted) to a variable.
    Also need to capture the 6.1.7600.16385 to a variable but once I see how its done I can do that.

    I had this working:
    Code:
    FOR /F "tokens=4 delims=:" %%A in ('!DISM! /image:!mountdir! /Get-CurrentEdition') do set currentedition=%%A
    ECHO.Ver output: !VER!
    But it stopped working on the other editions, ex: ultimate, core, etc.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    14,677
    18,882
    340
    #5 s1ave77, Apr 8, 2014
    Last edited by a moderator: Apr 20, 2017
    Hmm ... :

    Code:
    FOR /F "tokens=3 delims=: " %%A in ('%DISM% /image:%mountdir% /Get-CurrentEdition ^| findstr /i "Current Edition"') do set currentedition=%%A
    Code:
    C:\Windows\system32>FOR /F "tokens=3 delims=: " %A in ('%dism% /image:j:\win\mount /Get
    -CurrentEdition ^| findstr /i "Current Edition"') do echo %A
    
    C:\Windows\system32>echo Ultimate
    Ultimate
    
    C:\Windows\system32>FOR /F "tokens=3 delims=: " %A in ('%dism% /image:j:\win\mount2 /Ge
    t-CurrentEdition ^| findstr /i "Current Edition"') do echo %A
    
    C:\Windows\system32>echo Professional
    Professional
    
    C:\Windows\system32>FOR /F "tokens=3 delims=: " %A in ('%dism% /image:j:\win\mount3 /Ge
    t-CurrentEdition ^| findstr /i "Current Edition"') do echo %A
    
    C:\Windows\system32>echo HomePremium
    HomePremium
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    14,677
    18,882
    340
    #6 s1ave77, Apr 8, 2014
    Last edited by a moderator: Apr 20, 2017
    Code:
    FOR /F "tokens=2 delims=: " %%A in ('%DISM% /image:%mountdir% /Get-CurrentEdition ^| findstr /i "Version"') do echo %%A


    Code:
    C:\Windows\system32>FOR /F "tokens=2 delims=: " %A in ('%dism% /image:j:\win\mount3 /G
    t-CurrentEdition ^| findstr /i "Version"') do echo %A
    
    C:\Windows\system32>echo 6.3.9600.17029
    6.3.9600.17029
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #7 Humphrey, Apr 8, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Works. Thanks s1ave77. Once I get this a little bit further completed I will post. Till then :)


    Well the way I had in mind of doing it would have needed to use dism twice which is a time killer.

    Look for either a simple way of adding onto
    Code:
    FOR /F "tokens=2 delims=: " %%A in ('%DISM% /image:%mountdir% /Get-CurrentEdition ^| findstr /i "Version"') do echo %%A
    for it to get current edition and version.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    14,677
    18,882
    340
    #8 s1ave77, Apr 8, 2014
    Last edited by a moderator: Apr 20, 2017
    'for' loops are really cool, using this to get info from a WIM:

    Code:
        cls
        echo:
        echo ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
         Echo Checking All Indices  
        echo:
        echo ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
        echo:
        for /r %%f in (%path2%) do (
            set ext1=%%~xf
            if "!ext1!"==".wim" set ext1=WIM
            if "!ext1!"==".esd" set ext1=ESD
        )
        echo %ext1%: %path2%
        echo:
        echo:
        echo ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
        echo IND  MODIFIED    LP  ARC  BUILD           EDITION
        echo:
        echo ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
        for /f "tokens=2 delims=: " %%a in ('DISM /Get-WimInfo /WimFile:"%path2%" ^| findstr /i Index') do (
            for /f "tokens=2 delims=: " %%i in ('DISM /Get-WimInfo /WimFile:"%path2%" /Index:%%a ^| findstr /i Architecture') do set arch=%%i
            for /f "tokens=2 delims=:" %%k in ('DISM /Get-WimInfo /WimFile:"%path2%" /Index:%%a ^| findstr /i Version') do set b1=%%k
            for /f "tokens=3 delims=: " %%m in ('DISM /Get-WimInfo /WimFile:"%path2%" /Index:%%a ^| findstr /i Build') do set b2=%%m
            for /f "tokens=2 delims=- " %%m in ('DISM /Get-WimInfo /WimFile:"%path2%" /Index:%%a ^| findstr /i ^(Default^)') do set lang=%%m
            for /f "tokens=2 delims=:-" %%m in ('DISM /Get-WimInfo /WimFile:"%path2%" /Index:%%a ^| findstr /i Modified') do set mod=%%m
            for /f "tokens=2 delims=:" %%g in ('DISM /Get-WimInfo /WimFile:"%path2%" /Index:%%a ^| findstr /i Name') do (
            echo [%%a] !mod! !lang!  !arch! !b1!.!b2! %%g
            echo:
            )
        )
    
    
    Output:

    Code:
    ███████████████████████████████████████████████████████████████████████████████████████
    
    Checking All Indices
    
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    
    
    WIM: J:\win\wim2\install.wim
    
    
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    
    IND  MODIFIED    LP  ARC  BUILD           EDITION
    
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    
    [1]  12.04.2011  DE  x64  6.1.7601.17514  Windows 7 HOMEBASIC
    
    [2]  12.04.2011  DE  x64  6.1.7601.17514  Windows 7 HOMEPREMIUM
    
    [3]  12.04.2011  DE  x64  6.1.7601.17514  Windows 7 PROFESSIONAL
    
    [4]  12.04.2011  DE  x64  6.1.7601.17514  Windows 7 ULTIMATE
    
    
    ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
    
    
    Drücken Sie eine beliebige Taste . . .
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    What is this from as Id like the full script.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    14,677
    18,882
    340
    It's the DISM part of my tool (3rd link in my sig), you'll find DISM.cmd in \files\adk\ folder :D.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    #11 Compo, Apr 8, 2014
    Last edited by a moderator: Apr 20, 2017
    Here:
    Code:
    For /F "Tokens=1,2* Delims=: " %%A In (
    '%DISM% /Image:%mountdir% /Get-CurrentEdition') Do (
    If %%A Equ Version Set VER=%%B
    If %%B Equ Edition Set currentedition=%%C
    )
    Echo( %%VER%% = %VER%
    Echo( %%curentedition%% = %currentedition%
    Additional Info:
    Here is a better version of the lower section of s1ave77's script using the same principal.
    Code:
    Echo=ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
    Echo=IND  MODIFIED    LP  ARC  BUILD           EDITION
    Echo=
    Echo=ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
    For /F "Tokens=1,2 delims=: " %%a In ('DISM /Get-WimInfo /WimFile:"%path2%"'
        ) Do (If %%a Equ Index (
                For /F "Tokens=1,2* Delims=-: " %%c In (
                    'DISM /Get-WimInfo /WimFile:"%path2%" /Index:%%b') Do (
                        If %%c Equ Name (Set name=%%d %%e) Else (
                            If %%c Equ Architecture (Set arch=%%d) Else (
                                If %%c Equ Version (Set b1=%%d) Else (
                                    If %%d Equ Build (Set b2=%%e) Else (
                                        If %%c Equ Modified (Set mod=%%d) Else (
                                            If "%%e" Equ "(Default)" (Set lang=%%d)
                                            ))))))
                    Echo=[%%b]  !mod!  !lang!  !arch!  !b1!.!b2!  !name!
                    Echo=
        ))
     
  12. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #12 Humphrey, Apr 11, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Okay, think maybe it is time I posted the full script for when I get assistance now.


    Code:
    @echo off
    setlocal ENABLEDELAYEDEXPANSION
    TITLE Humphrey's %~nx0
    CD /D %~dp0
    IF NOT EXIST "WorkDir" MD WorkDir & MD WorkDir\Mount & MD WorkDir\Images & MD WorkDir\ISO
    SET inputfile=%1%
    SET WorkDir=.\WorkDir
    SET MountDir=!WorkDir!\Mount
    SET ISO=!WorkDir!\ISO
    SET Images=!WorkDir!\Images
    IF "%~1"=="" GOTO :Check
    IF "%~n1"=="WorkDir" GOTO :Credit
    :Check
    IF /i not "%~x1"==".wim" (
        CLS 
        TITLE How to use %~nx0
        ECHO.
        ECHO. ===============================================
        ECHO.                  Instructions
        ECHO. ===============================================
        ECHO.
        ECHO. %~nx0 is meant for modifiying WIM files and must 
        ECHO. have a .WIM file dropped onto it.  
        ECHO.
        ECHO. Drag and drop an Install.wim onto %~nx0.
        ECHO.
        ECHO.
        ECHO. File: !inputfile! is NOT a WIM file. 
        ECHO. Drop one onto %~nx0 to proceed. 
        PAUSE >NUL&EXIT
    ) ELSE (
        GOTO :DISMCheck
    )
    :DISMCheck
    :: Checks for DISM
    IF "!PROCESSOR_ARCHITECTURE!"=="AMD64" (SET _ProF=!ProgramFiles^(x86^)!) ELSE (    SET _ProF=!ProgramFiles!)
    SET DISM="!_ProF!\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\!PROCESSOR_ARCHITECTURE!\DISM\DISM.EXE"
    IF EXIST !DISM! (
        :: DISM found.
        GOTO :GetAdmin
    ) ELSE (
    :: DISM wasn't found.
    ECHO.
    ECHO. Couldn't locate DISM.exe at C:\Windows\System32\Dism.exe
    ECHO.
    SET /P altdism=Drag and drop Dism.exe here: 
    IF EXIST "!altdism!" (
        SET DISM=!altdism! 
        GOTO :GetAdmin
    ) ELSE (
    CLS&GOTO :DISMCheck
    )
    )
    
    :GetAdmin
    :: Request administrative permission.
    @(NET FILE||(powershell -command Start-Process '%0' -Verb runAs -ArgumentList '%* '&EXIT /B))>NUL 2>&1
    
    :: Get DISM version
    ECHO.
    ECHO. DISM Location: !DISM!
    FOR /F "tokens=2 delims=: " %%A in ('!DISM! /? ^| findstr /i "Version"') do SET _dVer=%%A
    
    :CommandCenter
    ECHO.
    ECHO. Dism Version: !_dVer!
    ECHO. ===============================================
    ECHO.                  DISM Commands
    ECHO. ===============================================
    ECHO. !currentedition!
    ECHO.
    ECHO. [0] Mount %~nx1    [1] Unmount !MountDir!
    ECHO. [2] Get %~nx1 info [3] Get !MountDir! info
    ECHO. [4] Change Language      [5]
    ECHO.
    choice /C 0123456789 /N /M "Select menu item:"
    if !ERRORLEVEL! EQU 1 CLS & GOTO :Mount
    if !ERRORLEVEL! EQU 2 CLS & GOTO :UnMount
    if !ERRORLEVEL! EQU 3 CLS & GOTO 
    
    :Mount
    !DISM! /Get-ImageInfo /ImageFile:!inputfile!
    ECHO.
    SET /P Index= Which index?: 
    CLS
    !DISM! /Mount-wim /wimfile:!inputfile! /Index:!INDEX! /Mountdir:!MountDir! 
    ECHO.
    ECHO. Gathering some info.
    For /F "Tokens=1,2* Delims=: " %%A In (
        '"!DISM!" /Image:!mountdir! /Get-CurrentEdition') Do (
        If %%A Equ Version Set VER=%%B
        If %%B Equ Edition Set currentedition=%%C
        )
    GOTO :CommandCenter    
    :UnMount
    ECHO.
    choice /C YN /N /M " Save to %~nx1 ?: "
    if !ERRORLEVEL! EQU 1 SET SAVE=/Commit
    if !ERRORLEVEL! EQU 2 SET SAVE=/Discard
    !DISM! /UNMount-wim /Mountdir:!MountDir! !SAVE!
    GOTO :CommandCenter    
    
    :SelfCheck
    ECHO.
    ECHO. ===============================================
    ECHO.                 Self Diagnosis
    ECHO. ===============================================
    ECHO.
    ECHO. DISM.exe: !DISM!
    ECHO. Input file: !inputfile!
    ECHO. Work Dir: !WorkDir!
    ECHO. Mount Dir:!MountDir!
    ECHO. ISO: !ISO!
    ECHO. Images: !Images!
    ECHO.
    PAUSE &GOTO :EOF
    :Credit
    :: People that assisted in the creation of this batch file.
    TITLE Credit is due.
    ECHO. ===============================================
    ECHO.               Special Thanks To
    ECHO. ===============================================
    ECHO.
    ECHO. BetonMAN - Amazing admin prompt.
    ECHO.
    ECHO. Compo - General scripting assistance.
    ECHO.
    ECHO. s1ave77 - General scripting assistance.
    ECHO.
    PAUSE >NUL & GOTO :EOF
    :EOF
    exit /b
    

    In BLUE I am having issue with it grabbing the wrong version. I've played with it a bit and cannot seem to figure it out.
    When running the command, you get two "Version"'s, the first one being the DISM version and the second is the IMAGE version.


    In RED I am getting 'C:\Program' for its variable output. Other instances of !DISM! function correctly afaik so I am not sure what is wrong here.


    I see pretty much the same code in blue that is in red, think I will adapt red to be like blue and see if that works. Sort of worked but not. :p

    @s1ave77: Looked at the batch files in jack of all trades or w/e and DAMN. So many lines of code.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    14,677
    18,882
    340
    #13 s1ave77, Apr 11, 2014
    Last edited by a moderator: Apr 20, 2017
    Would try this for the red part (the older phrase):

    Code:
    FOR /F "tokens=2 delims=: " %%A in ('%DISM% /image:%mountdir% /Get-CurrentEdition ^| findstr /i "Version"') do set _dVer=%%A
    No clue regarding compos lines, mine seem still to work :g:.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  14. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #14 Humphrey, Apr 11, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    When using your line, this is what I get.

    Code:
    'C:\Program' is not recognized as an internal or external command, operable program or batch file.
    
     Dism Version:
     ===============================================
                      DISM Commands
     ===============================================
    
     [0] Mount install.wim    [1] Unmount .\WorkDir\Mount
     [2] Get install.wim info [3] Get .\WorkDir\Mount info
     [4] Change Language      [5]
    
    Select menu item:
    
    Here is the command I would prefer to run seeing as it is meant to get the DISM version, it shouldn't run a DISM command other then help so that it isn't slower then what is required of it. (fyi, I get the same program if I run it as %DISM% /image:%mountdir% /Get-CurrentEdition)
    Code:
    ECHO.
    ECHO.%DISM%
    ECHO.
    FOR /F "tokens=2 delims=: " %%A in ('%DISM% /? ^| findstr /i "Version"') do set _dVer=%%A
    
    My echo.%dism% = "C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\AMD64\DISM\DISM.EXE"

    I think it has something to do with how !DISM! is being set or passed along. I used your line of code on its own in cmd prompt and it functions..

    Code:
    C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools>
    FOR /F "tokens=2 delims=: " %A in ('DISM /? ^| findstr /i "Version"') doset _dVer=%A
    
    C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools>
    set _dVer=6.3.9600.17029
    
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. s1ave77

    s1ave77 MDL Guide Dog/Dev

    Aug 15, 2012
    14,677
    18,882
    340
    #15 s1ave77, Apr 11, 2014
    Last edited by a moderator: Apr 20, 2017
    Try to change from:

    Code:
    SET DISM="!_ProF!\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\!PROCESSOR_ARCHITECTURE!\DISM\DISM.EXE"
    to:

    Code:
    SET "DISM=!_ProF!\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\!PROCESSOR_ARCHITECTURE!\DISM\DISM.EXE"
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #16 Humphrey, Apr 11, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Same results other then it force closes the batch.

    and with using that SET layout, %DISM% causes force close unless wrapped in quotes, if changed to !DISM! it doesn't force close.

    Either way, both produce the same output
    Code:
    'C:\Program' is not recognized as an internal or external command,operable program or batch file.
    
    Just fyi, if you attempt to use the batch file to see it run threw its paces then you must drop a install.wim onto the batchs icon on the desktop- or code into the batch around that.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    #17 Compo, Apr 11, 2014
    Last edited by a moderator: Apr 20, 2017
    Please see red code
     
  18. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #18 Humphrey, Apr 11, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Force closes
    Code:
    IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (SET _ProF=%%ProgramFiles(x86)%%) ELSE (SET _ProF=%%ProgramFiles%%)
    Had to escape the (x86)

    !DISM! = %ProgramFiles(x86)%\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\AMD64\DISM\DISM.EXE
    Code:
    IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (SET _ProF=%%ProgramFiles^(x86^)%%) ELSE (SET _ProF=%%ProgramFiles%%)
    Output = 'C:\Program' is not recognized as an internal or external command, operable program or batch file.


    !DISM! = C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\AMD64\DISM\DISM.EXE
    Code:
    IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (SET _ProF=!!ProgramFiles^(x86^)!!) ELSE (SET _ProF=!!ProgramFiles!!)
    Output = 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. Humphrey

    Humphrey MDL Expert

    Dec 13, 2011
    1,458
    981
    60
    #19 Humphrey, Apr 12, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    So after playing around for a bit I think I linked the issue to the
    Code:
    FOR /F "tokens=2 delims=: " %%A in ('%DISM% /? ^| findstr /i "Version"') do set _dVer=%%A
    findstr here. without that line everything seems to work better. o_O
    For now I will comment that out and continue with the rest of it.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    Humphrey,

    Someone allowed me access to their Windows PC today, (they actually wanted it repairing), so with no thought to the potential consequences I messed around with your script and I think I found the problem.

    It appears to have something to do with running dism.exe all the way down its tree.

    I decided to make my current directory that of the dism executable instead of the script location and had no problems simply replacing %DISM% with Dism.

    You will need to remember if using that method to use the full paths to .\WorkDir\ etc. instead.