Batch .CMD script to integrate ALL updates in offline image using DISM


  1. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
       #1

    Batch .CMD script to integrate ALL updates in offline image using DISM


    Good morning,

    I have the folder: C:\Win7ISOUpdates which contains ALL the Windows updates that I want to integrate into an offline image using DISM. I have numbers at the beginning of each of the updates so as they will be integrated in the order that I specify.

    The offline image is stored in: C:\Win7ISO\OFFLine.

    I created a Notepad file in C:\Win7ISOUpdates called SlipStrm.cmd.

    Within that file I used the command: For %%U in (*.msu) do Dism /Image:C:\Win7ISO\OFFLine /Add-Package /C:\Win7ISOUpdates:"%%U"

    I mounted the image: Dism /Mount-WIM /WimFile:C:\Win7ISO\sources\install.wim /Name:"Windows 7 HOMEPREMIUM" /MountDir:C:\Win7ISO\OFFLine

    I ran SlipStrm.cmd in an elevated command prompt and got an error message saying: "The C option is not recognised in this context.".

    Has anyone got any ideas please?

    Thanks in advance.
      My Computer


  2. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #2

    Good morning again,

    Would this work?

    I thought I would ask before I test it out later when I get home!!!

    I have set up a batch file: SlipStream.bat

    Code:
    @Echo off
    ::Set Paths
    :
    :Path to the Mounted OFFLine Folder
    Set MOF=C:\Win7ISO\OFFLine
    :
    :Path to the folder with ALL Update Packages
    Set AUP=C:\Win7ISOUpdates
    :
    CLS
    dism /Image:%MOF% /Add-Package /PackagePath:%AUP%
    Echo ........................................
    Echo Update integration complete!
    Pause
    Exit
    :
    Thanks in advance.
      My Computer


  3. Posts : 396
    Windows 7/8.1/10 multiboot
       #3

    Paul Black said:
    I ran SlipStrm.cmd in an elevated command prompt and got an error message saying: "The C option is not recognised in this context.".
    I don't use dism enough to really be conversant with it, but offhand I'd say that error msg points to this part:
    Within that file I used the command: For %%U in (*.msu) do Dism /Image:C:\Win7ISO\OFFLine /Add-Package /C:\Win7ISOUpdates:"%%U"
    Your command appears to have an unidentified "/C" parameter (aka, "option") ... should that perhaps be "/Add-Package /PackagePath:C:\Win7ISOUpdates\%%U"?

    Aside: I also don't think %%U needs to be in quotes unless any of your update files contain spaces in their filenames.

    However, you may have a bigger problem because this reference suggests dism does not support the .msu format.
      My Computer


  4. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #4

    Thanks for the reply dg1261,

    dg1261 said:
    Your command appears to have an unidentified "/C" parameter (aka, "option") ... should that perhaps be "/Add-Package /PackagePath:C:\Win7ISOUpdates\%%U"?

    Aside: I also don't think %%U needs to be in quotes unless any of your update files contain spaces in their filenames.
    I have got a space at the front of the filename after (01), (02), (03) etc so they will integrate in the correct order, hence the speach marks.
    I will definately try your suggestion tomorrow with regard to adding the /PackagePath and the \.

    dg1261 said:
    However, you may have a bigger problem because this reference suggests dism does not support the .msu format.
    That page is quite old (February 15, 2011) and things have changed since then.
    I can easily integrate an update using DISM offline by using:
    Dism /Image:C:\Win7ISO\OFFLine /Add-Package /PackagePath:C:\Win7ISOUpdates\windows6.1-kb3020369-x64.msu
    Please see image attached.

    I just want to be able to integrate ALL the updates in a folder at once as opposed to doing them individually.

    Thanks for you input on this, it is appreciated.

    I thought I would have had more interest on this topic but it doesn't seem that many people know about creating batch files!
    Attached Thumbnails Attached Thumbnails Batch .CMD script to integrate ALL updates in offline image using DISM-dism-update.jpg  
      My Computer


  5. Posts : 396
    Windows 7/8.1/10 multiboot
       #5

    Well, there 'ya go--notice the difference between what you posted in your post #1 vs. post #4:

    Paul Black said:
    Within that file I used the command: For %%U in (*.msu) do Dism /Image:C:\Win7ISO\OFFLine /Add-Package /C:\Win7ISOUpdates:"%%U"
    Paul Black said:
    I can easily integrate an update using DISM offline by using:
    Dism /Image:C:\Win7ISO\OFFLine /Add-Package /PackagePath:C:\Win7ISOUpdates\windows6.1-kb3020369-x64.msu
    In the first example, use the pattern you used in the second except substitute %%U for windows6.1-kb3020369-x64.msu . If you've discovered the .msu format is indeed supported, then I should think it ought to work.

    I interpreted this initially as a dism topic rather than a batch file topic, so skipped the thread because I'm not really that familiar with dism usage. Indeed, no SlipStrm.cmd is even necessary because you can just as simply issue the "for %%U..." command directly at the command prompt--although the proper syntax in that case would be single %'s at the command prompt vs. the double %% required for a batch file.

    Keep in mind the "for %U in (*.msu)" works only if your CWD (current working directory) is the same as where the .msu files are located, so make sure that's where you are before issuing the command. IOW ...

    If you've switched to the C:\Win7ISOUpdates directory, you can use:
    For %U in (*.msu) do Dism /Image:C:\Win7ISO\OFFLine /Add-Package /PackagePath:C:\Win7ISOUpdates\%U

    Or alternatively use the following from anywhere:
    For %U in (C:\Win7ISOUpdates\*.msu) do Dism /Image:C:\Win7ISO\OFFLine /Add-Package /PackagePath:%U

    Note the difference in the /PackagePath option in the second example because the full path is being captured in the "for" mask, whereas it is not in the first example.

    And, as mentioned above, double the % symbols if you do decide to embed this in SlipStrm.cmd.
      My Computer


  6. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #6

    Hi dg1261,

    dg1261 said:
    ...alternatively use the following from anywhere:
    For %U in (C:\Win7ISOUpdates\*.msu) do Dism /Image:C:\Win7ISO\OFFLine /Add-Package /PackagePath:%U
    Brilliant, that works perfectly .

    I am going to further investigate at some stage (because this is new to me) creating a Batch file so that it automatically goes through the folder updates one by one but after each update is successfully installed (or not as the case may be), pauses and tells you whether or not it has been successful and asks you to press any key to continue. When you press any key to continue it then continues with the installation of the next windows update in the folder. That will keep me out of trouble for a while.

    I think using a Batch file will make the whole integration process a lot smoother, and you never know, I might be able to get it to do the whole process!

    Thank you for all your help, advice, suggestions and time on this dg1261, it is very much appreciated.
    Last edited by Paul Black; 12 Mar 2018 at 14:29.
      My Computer


  7. Posts : 396
    Windows 7/8.1/10 multiboot
       #7

    Paul Black said:
    I am going to further investigate at some stage (because this is new to me) creating a Batch file so that it automatically goes through the folder updates one by one but after each update is successfully installed (or not as the case may be), pauses and tells you whether or not it has been successful and asks you to press any key to continue. When you press any key to continue it then continues with the installation of the next windows update in the folder.
    That's easy to do with two batch scripts: a master "do-all-updates" script repeatedly calling a "do-one-update" script. Here's a quick-and-dirty example to illustrate the technique:

    save this as do-one.cmd:
    Code:
    @echo off
    echo %1
    pause
    save this as do-all.cmd:
    Code:
    @echo off
    for %%d in (1 3 alpha baby) do call do-one.cmd %%d
    When you execute do-all.cmd it will sequentially call do-one.cmd repeatedly until it completes the "for" loop.

    A couple notes to explain what's going on:

    As opposed to "do", "do call" tells the second script to return to the first script when it's done.

    The %1 is a way to pass variables from one file to the other. The do-all.cmd will sequentially call "do-one 1", "do-one 3", etc. The %1 parameter tells the receiving script to use the first word in the command tail as a variable.

    Good luck when you eventually get around to playing with this! Hopefully this note will help get you started.
      My Computer


  8. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #8

    Thanks very much dg1261, your instructions and advice will come in very handy when I get round to this and will certainly help me to get started.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:25.
Find Us