Microsoft (Office|Workflow) Windows

How to remove OneDrive from Windows via DISM

Microsoft OneDrive

Microsoft OneDrive is software that enables two-way cloud backup. It helps you to store and protect your data, as well as share and view them from any device. You can also change the file’s location. OneDrive is preloaded in Windows 10 and 11, which means OneDrive will be automatically installed when you upgrade to either Windows. If you are deploying windows on many PC using windows ISO file and does not want to have OneDrive preinstalled on those system, it will be better to have the Windows ISO file modified before proceeding.   

You can modify an ISO file using a tool in Windows called DISM (Deployment Image Servicing and Management), a native Windows program. DISM is a command-line program that can be used to add registry entries and modify the default Windows install image. Please see: Cannot uninstall the OneDrive App: The item “OneDrive” can’t be moved to the Bin because it’s open on Mac and How to Disable or Uninstall OneDrive on Windows 10 and 11.

With the DISM command option you will be able to access the Windows install image and remove the OneDriveSetup preloaded in the disk image to prevent it from auto installing during Windows setup. Here are other related guides: Cannot uninstall the OneDrive App: The item “OneDrive” can’t be moved to the Bin because it’s open on Mac, How to Disable or Uninstall OneDrive on Windows 10 and 11, Install Wim: How to Add Packages to Windows image the DISM ToolRemove Windows 10 Apps with DISM: How to remove pre-provisioned apps from Windows Image, for common DISM errors see: Error 183: The specified image is currently being serviced by another DISM operation.

In this guide, we will see two method to remove OneDrive from Windows via DISM. I will be using a Windows 11 ISO image file in this example, but the technique is the same whether you use a Windows 10 ISO image.

Method 1: Mount ISO to Remove OneDrive Using DISM

To mount a Windows ISO image double click the ISO file to automatically open it as a virtual DVD in the File Explorer. Open the mounted ISO in Explorer, select all files and directories, then copy and paste the ISO content into a folder.

Window 11 disk image

In this guide, I created a folder in the root directory on disk C: and name the folder Win11_ISO.

Win11_ISO in root directory

Make a folder to hold the offline image. In this example, I created a folder called Mount in the root folder C:\Mount.

Folder to Mount disk image for DISM operation

Open the Windows Start Menu and search for PowerShell, then run as administrator.

Running PowerShell in Start menu

Enter the following command to check what editions are included in the disk image:

Dism /Get-WimInfo /WimFile:C:\Win11_ISO\Sources\install.wim
PowerShell: checking windows editions
Note the index number of your selected edition. In this example I want to use Windows 11 PRO edition to edit its registry, noting its index number 6.

Mount the image of your preferred Windows edition using its index number, index 6 in this example:

Dism /Mount-Wim /WimFile:C:\Win11_ISO\Sources\install.wim /index:6 /MountDir:C:\Mount
PowerShell: Mounting disk image

The mounting image process will take some time to complete. You can check the Mount folder in C: Mount to see the Windows image files.

Mounted Windows image files

Please keep in mind that the disk where the Mount folder is situated requires some free space. It is recommended to utilize a machine with a disk that has more than 15 GB of free space.

Now go to Windows\SysWOW64 search for OneDriveSetup and delete it.

Deleting OneDrive installation file

Unmount the offline image and commit (save) changes using the following command:

Dism /Unmount-Image /MountDir:C:\mount /Commit
PowerShell: Unmount and save changes to disk image

Method 2: Edit ISO Registry Hive to Remove OneDrive Using DISM

To remove OneDrive, we need to edit the offline registry hive by importing it to a temporary hive in the host registry. In this example, I will import the HKLM\Software hive from the offline registry to a temporary hive called Offline in the host registry:

Powershell: add registry hive to host registry

To see the new Offline registry hive created, open the Registry Editor and click on HKEY_LOCAL_MACHINE to view the hive.

Registry Editor: registry hive (Offline) added to host registry

Navigate to the following path:


Then delete the Run OneDriveSetup key.

Registry Editor: Deleting OneDrive Setup

When you’re through with registry changes, use the following command to unload the temporary hive:

reg unload HKLM\Offline
PowerShell: Removing registry hive (Offline)

The reg unload command removes the temporary hive from the host registry.

Registry Editor: Registry hive (Offline) removed from host registry

Unmount the offline image and commit (save) changes using the following command:

Dism /Unmount-Image /MountDir:C:\mount /Commit
PowerShell: Unmount and save changes to disk image

You can now install Windows, which includes your modification by default.

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x