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

Discussion in 'Windows 7' started by Paul_Black, Mar 11, 2018.

1. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
Good evening, I am after some help on a clean install of Windows 7 SP1 x64 please!

I have the folder: C:\Win7ISOUpdates which contains ALL the Windows updates (.msu) 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 numerical order specified.

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

First Attempt:

Within that file I used the command:

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

I executed SlipStream.cmd in an elevated command prompt from within the C:\Win7ISOUpdates folder and got an error message saying: "The C option is not recognised in this context.".

Second Attempt:

Then I did a lot of research on the Internet about using a Batch file to accomplish this and this is what I came up with (I have never done this before so please don't laugh).

I created 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
:
CLS
Echo ........................................
Echo Update integration complete!
Pause
Exit```
Can anyone please tell me if this is correct?

2. ### hearywarlot MDL Member

Jul 31, 2015
112
111
10
Hello Paul_Black,
The thing you want to do, creating a fully uptodate ISO of Windows 7 SP1 has already several easy to use and actively maintained solutions.

There is a solution by Simplix from the OSZone forum:
https://forums.mydigitallife.net/th...egrate-hotfixes-into-win7-distribution.45005/

You have several easy to use scripts for slipstreaming the downloaded packages:
MSMG's toolkit:

Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
3. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#3
Last edited: Mar 13, 2018
(OP)
Thanks for the reply hearywarlot, it is appreciated.

There is indeed a lot of alternatives and useful information there, thank you.

However, I really wanted to do this as a batch file.

4. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#4 (OP)
Good morning,

Perhaps this will be easier to accomplish.

Here is the setup (Windows 7 x64 with WAIK installed):

C:\Win7ISO - Folder where the Win7ISO files have been extracted to.
C:\Win7ISO\OFFLine - Folder used to mount the install.wim file.
C:\Win7ISOUpdated - Where the NEW ISO image will be saved into.

How can I put the following into a Batch File and run it against a mounted offline install.wim file please?

Step 1 (make the directory for the offline image):
mkdir C:\Win7ISO\OFFLine

Step 2 (mount the install.wim offline):
Dism /Mount-WIM /WimFile:C:\Win7ISO\sources\install.wim /Name:"Windows 7 HOMEPREMIUM" /MountDir:C:\Win7ISO\OFFLine

Step 4 (unmount the offline image and commit all the changes made):
Dism /Unmount-WIM /MountDir:C:\Win7ISO\OFFLine /Commit

Step 5 (cleanup any leftovers):
DISM /Cleanup-Wim

Step 6 (delete the directory for the offline image which is now empty as it is not needed and so will not be included in the newly created ISO):
DELETE C:\Win7ISO\OFFLine

Step 7 (Create the new ISO):
Oscdimg -bootdata:2#p0,e,bC:\Win7ISO\boot\etfsboot.com#pEF,e,bC:\Win7ISO\efi\microsoft\boot\Efisys.bin -u1 -udfver102 C:\Win7ISO C:\Win7ISOUpdated\Win7ISOUpdated.iso

5. ### mehdibleu MDL Expert

Jun 14, 2017
1,012
214
60
From the error message that you got ""The C option is not recognised in this context." , i think that the correct command would be :

6. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#6 (OP)

I tried your suggestion (using 3 updates in the updates folder as a test) and it did indeed go through the 3 updates in the folder and said it completed successfully at the end.
However, the updates bar showed 100% complete for update 1 but for the other 2 it only showed 97.7% complete for example.

7. ### mehdibleu MDL Expert

Jun 14, 2017
1,012
214
60
if you saw "the operation completed successfully" to appear, that means that all went smoothly and that the updates were integrated successfully.

8. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#8
Last edited: Mar 14, 2018
(OP)

I have been trying to learn writing a Batch script and have come up with this called Test.bat (please let me know if I shouldn't run this before I do and muck anything up!):
Code:
```@Echo off
Title Create a new install.wim File!
mkdir C:\Win7ISO\OFFLine
Pause
Echo Mounting...
Dism /Mount-WIM /WimFile:C:\Win7ISO\sources\install.wim /Name:"Windows 7 HOMEPREMIUM" /MountDir:C:\Win7ISO\OFFLine
Pause
Pause
Echo Un-mounting...
Dism /Unmount-WIM /MountDir:C:\Win7ISO\OFFLine /Commit
Pause
Echo Cleaning up...
DISM /Cleanup-Wim
Pause
Echo Deleting directory...
rmdir C:\Win7ISO\OFFLine
Pause
Echo Creating ISO...
Oscdimg -bootdata:2#p0,e,bC:\Win7ISO\boot\etfsboot.com#pEF,e,bC:\Win7ISO\efi\microsoft\boot\Efisys.bin -u1 -udfver102 C:\Win7ISO C:\Win7ISOUpdated\Win7ISOUpdated.iso
Pause
Exit```

(1) Where does the Batch file need to be run from (i.e. in what directory should I save the Batch file and then right click it and run it as Administrator)?
EDIT: Or is the fact that I right click it and run it as Administrator enough?
(2) How can I make sure that is uses an Elevated Command Prompt when running the script?
(3) When creating the new ISO using Oscdimg it needs to be run from:
Start > Microsoft Windows AIK > Right Click Deployment Tools Command Prompt > Run as Administrator
How can I get it to do this please?

I have put this together from investigation on many sites.

9. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#9
Last edited: Mar 14, 2018
(OP)
10. ### mehdibleu MDL Expert

Jun 14, 2017
1,012
214
60
#10
Last edited: Mar 15, 2018
Sorry mate but i cannot help you much more with this, you will have to ask someone who is really good at programming so he can answers all your questions with detailed explanation.
If i go by what you show about the batch file, i would say it's good enough but i would change some command lines :

Code:
```@Echo off
Title Create a new install.wim File!
mkdir C:\Win7ISO\OFFLine
Pause
Echo Mounting...
Dism /Mount-WIM /WimFile:C:\Win7ISO\sources\install.wim /Name:"Windows 7 HOMEPREMIUM" /MountDir:C:\Win7ISO\OFFLine
Pause
Pause
Echo Un-mounting...
Dism /Unmount-WIM /MountDir:C:\Win7ISO\OFFLine /Commit
Pause
Echo Cleaning up...
DISM /Cleanup-Wim
Pause
Echo Deleting directory...
rmdir C:\Win7ISO\OFFLine
Pause
cd c:\tools
Echo Creating ISO...
Oscdimg -betfsboot.com -n -h c:\flat c:\windows7HomePremium.iso
Pause
Exit```
Before running the batch file, create a folder called C:\tools then go to Microsoft Windows AIK and find both of these files (oscdimg.exe and etfsboot.com) and put them into c:\tools
Create a folder called c:\flat then extract your Windows 7 ISO and put the files in C:\flat

Then run the batch file and see the result. (don't forget to remove
assuming that you put the updates into the folder Win7ISOUpdates from the file)

To test this, you can use VM, that'w what i do for all my tests, you can also test your batch configuration as well into VM.

11. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#11
Last edited: Mar 15, 2018
(OP)
Thanks for the reply mehdibleu, I will try out your suggestions later when I get home.

I just thought I would come up with a few other ideas as well so I can try them too if they don't work.

For the main part of the Batch script which needs to be run in an elevated command (Administrator):

If I opened an elevated command prompt and then run the Batch file from there, would the commands inside the Batch file be run as Administrator?

When I right clicked the .bat > Properties > Compatability, the Privilage Level for Run this program as an Administrator was greyed out!

I then created a shortcut for the .bat file, I right clicked on it > Properties > Shortcut tab > Advanced > and checked Run as administrator. So am I assuming that this would now execute the Batch commands as an Administrator (except the oscdimg command obviously)?

For the oscdimg part of the script which needs to be run in an elevated command (Administrator):

Could I not put the full path to the oscdimg.exe C:\Program Files\Windows AIK\Tools\amd64\oscdimg.exe at the beginning of the command so it executes directly from the right directory?

The reason I used...
Oscdimg -bootdata:2#p0,e,bc:\Win7ISO\boot\etfsboot.com#pEF,e,bc:\Win7ISO\efi\microsoft\boot\Efisys.bin -u1 -udfver102 C:\Win7ISO C:\My.iso
...was so that it included efi support as well.

I just want to have a few options for when I test it.
My x64 computer is a few years old now and the BIOS doesn't have the Virtualisation facility so I can't test in a free x64 VM.

12. ### mehdibleu MDL Expert

Jun 14, 2017
1,012
214
60
#12
Last edited: Mar 15, 2018

You can simply right click on the batch file then click on "run as administrator"

No need to do this, again you can simply right click on the batch file then click on "run as administrator" and it should work.

Yes that should does the job as well, you can simply test it and you will see the result.

Again, i am not an expert, i just try to help as much as i can with the knowledge i have. If you want to have more detailted information about all this , you should contact someone as @abbodi1406 or @AnarethoS (both of these guys are great programmers, i'm sure they will answer all your questions )

13. ### s1ave77 MDL Guide Dog/Dev

Aug 15, 2012
15,055
20,254
340
Regarding the admin elevation of a script there's no need to reinvent the wheel. Just check the existing script solutions here at MDL for the several ways to skin the cat .

Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

May 21, 2007
8,709
3,066
300
15. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#15 (OP)
Thanks for the link urie, it is very much appreciated.
I will investigate those further.
At least I know where to look now!
Have a great weekend.

16. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#16
Last edited: Mar 16, 2018
(OP)
Good afternoon,

I have managed to get EVERYTHING in the Batch file to run successfully EXCEPT the last part, the Oscdimg.

I tried running it as one line and then I tried changing the directory and then running it.
I have included the two screen shots of the results.

I am almost there!

Any help will be greatly appreciated.

EDIT:
I think I've cracked it...
Code:
```cd C:\Program Files\Windows AIK\Tools\amd64\

oscdimg.exe -bootdata:2#p0,e,bC:\Win7ISO\boot\etfsboot.com#pEF,e,bC:\Win7ISO\efi\microsoft\boot\Efisys.bin -u1 -udfver102 C:\Win7ISO C:\Win7ISOUpdated\Win7ISOUpdated.iso```

File size:
35.7 KB
Views:
8
File size:
37.1 KB
Views:
8
17. ### Paul_Black MDL Novice

Feb 20, 2018
15
1
0
#17 (OP)
Good evening,

Well everything went well.

I have one small problem though.
I run...
Code:
`Dism /Image:"C:\Win7ISO\OFFLine" /Add-Package /PackagePath:"C:\Win7ISOUpdates"`
...which when it finishes running shows the screenshot attachment below where it doesn't show 100%.

Is there a way I can get it to wait for a few seconds after each update before it goes onto the next one so it can catch up please?

File size:
12 KB
Views:
10
18. ### mehdibleu MDL Expert

Jun 14, 2017
1,012
214
60
As i said last time, no need to worry about the bar progress not reaching 100%, as long as you get the message "the operation completed successfully", that means that all the updates were integrated successfully.

19. ### Enthousiast MDL Tester

Oct 30, 2009
15,419
18,438
340
As long as it shows the " operation completed successfully" it's alright.

20. ### mehdibleu MDL Expert

Jun 14, 2017
1,012
214
60
it's already said from post just above yours
{"extraction_info": {"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8755205869674683, "perplexity": 4504.838354219635}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-34/segments/1534221210105.8/warc/CC-MAIN-20180815122304-20180815142304-00399.warc.gz"}