3

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?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
zer0
  • 31
  • 1
  • 4
  • DISM is tricky. Was anything running before the unmount-wim of registry changes not fully installed? Did the C:\winpe_amd64\mount directory exist before the mount-wim? You may need delays after mounting and before unmounting wim file. – James Furst Jul 15 '20 at 18:09
  • Error: 0xc1420117 mostly occures, if I still have an Explorer or command window opened in the mounted folder somewhere behind other windows. Sometimes these windows close automatically, what results in orphaned mount-points. This is just what I discovered. Doesn't need to cover your issue – Mahobo Jul 20 '20 at 14:03

1 Answers1

0

In my case, I was trying to umount image in Windows 11.

After many tried and research, Following solutin worked for me.

Simply close the folder in which image is available. In my case I closed "C:\winpe" and then run unmount command. And it works fine.

enter image description here

prisan
  • 1,251
  • 12
  • 9