cleanup-wim says successful in batch, but wim is still orphaned

1

This is my first post here, but have been using stackoverflow for a while for any of the problems I run in to.

(TL;DR: my batch script says that it successfully unmounts the WIM file, but when I query for WIMs, orphaned files are still around until I run /cleanup-wim manually.)

I'm attempting to make a batch file for modifying a Win PE image, but am having trouble with the last step.

Basically my script is first creating the amd64 win PE architecture, mounting the WIM file, editing the registry hive for the SYSTEM file (and then closing the hive), copying files to specific folders, then is supposed to unmount the WIM, and create an ISO that can be burned to a disk or copied onto a bootable USB.

Everything works, except for the unmount portion.

To give you insight of how this is first being done, I run:

C:\windows\system32\Dism.exe /Mount-Wim /WimFile:C:\winpe_amd64\media\sources\boot.wim /index:1 /MountDir:C:\winpe_amd64\mount

After the registry changes, file creations, etc., I later run:

C:\windows\system32\Dism.exe /Unmount-Wim /MountDir:C:\winpe_amd64\mount /commit
C:\windows\system32\Dism.exe /cleanup-wim

With /unmount-wim, I will sometimes receive this error:

Image File : C:\winpe_amd64\media\sources\boot.wim
Image Index : 1
Saving image
[==========================100.0%==========================]
Unmounting image
[==========================100.0%==========================]

Error: 0xc1420117

The directory could not be completely unmounted.  This is usually due to applications that still have files opened within the mount directory.  Close these files and unmount again to complete the unmount process.

The DISM log file can be found at C:\windows\Logs\DISM\dism.log

Which is why I implemented /cleanup-wim into my script. which elicits:

Unmounting image at C:\winpe_amd64\mount
[==========================100.0%==========================]
Scanning drive C for stale files
The operation completed successfully.

However, this is what returns when I query for any mounted WIMs, regardless if the initial /unmount-wim is fully successful or not:

C:\windows\system32\dism.exe /get-mountedwiminfo


Mount Dir : C:\winpe_amd64\mount
Image File : C:\winpe_amd64\media\sources\boot.wim
Image Index : 1
Mounted Read/Write : Yes
Status : Invalid

The operation completed successfully.

And if I run /cleaup-wim once more manually, it will finally unmount successfuly:

Unmounting image at C:\winpe_amd64\mount
[==========================100.0%==========================]
Scanning drive C for stale files
The operation completed successfully.

Once I query once more, no mounted/orphaned WIMs are found. I also tried making my batch script wait 5 seconds between /unmount-wim and /cleanup-wim, but still had the same result. I also called another batch script with the cleanup command, but still no dice.

Any suggestions?

batch-file
winpe
dism
asked on Stack Overflow Apr 21, 2016 by zer0 • edited Jul 4, 2018 by Daniel A. White

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0