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

Paul Black

I WANT TO BELIEVE!
Guru
VIP
Local time
12:25 PM
Messages
3,823
Location
Planet Earth VGhlIFgtRmlsZXM=
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

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
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 [B][COLOR=red]M[/COLOR][/B]ounted [B][COLOR=red]O[/COLOR][/B]FFLine [B][COLOR=red]F[/COLOR][/B]older
Set [B][COLOR=red]MOF[/COLOR][/B]=C:\Win7ISO\OFFLine
:
:Path to the folder with [B][COLOR=blue]A[/COLOR][/B]LL [B][COLOR=blue]U[/COLOR][/B]pdate [B][COLOR=blue]P[/COLOR][/B]ackages
Set [B][COLOR=blue]AUP[/COLOR][/B]=C:\Win7ISOUpdates
:
CLS
dism /Image:%[B][COLOR=red]MOF[/COLOR][/B]% /Add-Package /PackagePath:%[B][COLOR=blue]AUP[/COLOR][/B]%
Echo ........................................
Echo Update integration complete!
Pause
Exit
:

Thanks in advance.
 

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
Thanks for the reply dg1261,

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 \.

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!
 

Attachments

  • DISM Update.jpg
    DISM Update.jpg
    25.3 KB · Views: 33

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
Well, there 'ya go--notice the difference between what you posted in your post #1 vs. post #4:

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

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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
Hi dg1261,

...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 :thumbsup:.

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:

My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
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

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Optiplex 7050
OS
Windows 7/8.1/10 multiboot
CPU
Intel Core i7-7700
Motherboard
Dell, Intel Q270 chipset
Memory
48GB (2x16GB Crucial DDR4-3200 + 2x8GB Hynix DDR4-2400)
Graphics Card(s)
Intel HD630 + AMD Radeon R7 450 PCIe
Monitor(s) Displays
Asus VC279 (27")
Screen Resolution
1920x1080
Hard Drives
Toshiba M.2 NVMe (256GB),
Samsung 960 Evo (500GB),
WD Red Plus 80EFBX (8TB)
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

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
Back
Top