Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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

10 Mar 2018   #1
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 
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 System SpecsSystem Spec
.
10 Mar 2018   #2
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

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 System SpecsSystem Spec
11 Mar 2018   #3
dg1261

Windows 7/8.1/10 multiboot
 
 

Quote   Quote: Originally Posted by Paul Black View Post
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:
Quote:
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 System SpecsSystem Spec
.

11 Mar 2018   #4
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Thanks for the reply dg1261,

Quote   Quote: Originally Posted by dg1261 View Post
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 \.

Quote   Quote: Originally Posted by dg1261 View Post
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 Images
Batch .CMD script to integrate ALL updates in offline image using DISM-dism-update.jpg 
My System SpecsSystem Spec
11 Mar 2018   #5
dg1261

Windows 7/8.1/10 multiboot
 
 

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

Quote   Quote: Originally Posted by Paul Black View Post
Within that file I used the command: For %%U in (*.msu) do Dism /Image:C:\Win7ISO\OFFLine /Add-Package /C:\Win7ISOUpdates:"%%U"
Quote   Quote: Originally Posted by Paul Black View Post
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 System SpecsSystem Spec
12 Mar 2018   #6
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi dg1261,

Quote   Quote: Originally Posted by dg1261 View Post
...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.
My System SpecsSystem Spec
12 Mar 2018   #7
dg1261

Windows 7/8.1/10 multiboot
 
 

Quote   Quote: Originally Posted by Paul Black View Post
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 System SpecsSystem Spec
12 Mar 2018   #8
Paul Black

7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

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 System SpecsSystem Spec
Reply

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




Thread Tools




Similar help and support threads
Thread Forum
Help me integrate a Powershell script into the context menu
Hi all, I want to add a custom entry to the right-click context menu so that I can send a copy of a file to a predetermined folder on a remote computer. This idea is based on a tutorial. I stored a Powershell script in C:\context-menu.ps1. There should only be one argument (which is the file's...
General Discussion
how to integrate/slipstream new updates
I'm new to this and to Win7, my terminology may not be accurate. For the first time, yesterday I created custom media for installing Win7 and used it successfully. It was really easy. Essentially, I created and executed a slip.cmd file. The file contained various dism commands. My approach...
Installation & Setup
Updates not injecting into image using DISM
Is this forum a good place for posting WDS related question? If not please direct me to the correct forum. Thank you. Issue, short version: after running DISM commands to inject updates to the WDS images, we use the image on a box and there are no new updates installed. Only the originally...
Windows Updates & Activation
Batch download for updates? Recently restored image
Hello all! I recently restored W7 Home Premium from an image, made using the W7 backup/restore tool. The hard drive I made the image on completely died, thus I restored the image to a different drive, different manufacturer. Now all of my updates are gone, or at least several months' worth. I...
Windows Updates & Activation
DISM - Deployment Image Servicing and Management tool
I found this tool while searching the system32 folder: DISM.EXE C:\Users>dism Deployment Image Servicing and Management tool Version: 6.1.7048.0 DISM.exe {WIM_command}
Backup and Restore


Our Sites

Site Links

About Us

Find 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 15:29.
Twitter Facebook Google+