You may be unable to install or update Store apps. Also, when you run the Get-AppxPackage command, the following error may appear:
Get-AppxPackage : The database disk image is malformed The database disk image is malformed At line:1 char:1 + Get-AppxPackage + ~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-AppxPackage], Exception + FullyQualifiedErrorId : System.Exception,Microsoft.Windows.Appx.PackageManager.Commands.GetAppxPackageCommand
Cause
The “The database disk image is malformed” occurs if the State Repository database is corrupt. This database stores information about every Store app installed on the computer. The database file names are below:
- StateRepository-Deployment.srd
- StateRepository-Deployment.srd-shm
- StateRepository-Deployment.srd-wal
- StateRepository-Machine.srd
- StateRepository-Machine.srd-shm
- StateRepository-Machine.srd-wal
Unfortunately, a repair installation using an in-place upgrade using the ISO may not resolve the issue.
However, resetting the StateRepository databases manually should fix the issue.
Resolution
To fix the error “The database disk image is malformed”, rebuild the State Repository database.
Important: Following the procedure below, you will lose all your installed Store apps, but you can reinstall them again.
Rebuilding the State Repository database
- Download AdvancedRun from Nirsoft.net.
- Using AdvancedRun, open a TrustedInstaller Command Prompt. See the screenshot below.
- After the Command Prompt window opens, close the AdvancedRun utility.
- In the TrustedInstaller Command Prompt, run the following commands:
md C:\SRBackup
cd /d C:\ProgramData\Microsoft\Windows\AppRepository
sc config staterepository start= disabled
net stop StateRepository
Note: If you’re prompted to stop the Appx Deployment Service (AppxSVC) service, press Y to proceed. And, if the above command does not stop the State Repository service, you’ll get the error “The StateRepository service could not be stopped”. In that case, rerun the above command again.
Then, run these commands:move StateRepository-* C:\SRBackup
sc config staterepository start= demand
The above procedure moves the existing State Repository database files to a folder for backup purposes.
Restart Windows. Or, click the Start button or an item in your notification area. This starts the State Repository service automatically and rebuilds the databases. A fresh set of StateRespository-* databases will be created. The newly built database will not contain information about your previously installed Store apps.
This resolves the error “The database disk image is malformed” when running Get-AppxPackage and allows you to install the Store apps.
One small request: If you liked this post, please share this?
One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:- Pin it!
- Share it to your favorite blog + Facebook, Reddit
- Tweet it!
Been having this problem for some time now, and the most recent Windows Update for Win 10 has now caused my entire Windows “system” apparatus to be non-functional (no start menu, can’t access anything that would be considered a “base windows” function, like the search bar or even the clock!). I tried your steps listed here, but the final step was blocked because the files were still being used by another process.
C:\WINDOWS\system32>cd /d C:\ProgramData\Microsoft\Windows\AppRepository
C:\ProgramData\Microsoft\Windows\AppRepository>net stop StateRepository
The following services are dependent on the State Repository Service service.
Stopping the State Repository Service service will also stop these services.
AppX Deployment Service (AppXSVC)
Do you want to continue this operation? (Y/N) [N]: y
The AppX Deployment Service (AppXSVC) service is stopping…
The AppX Deployment Service (AppXSVC) service was stopped successfully.
The State Repository Service service is stopping.
The State Repository Service service was stopped successfully.
C:\ProgramData\Microsoft\Windows\AppRepository>md C:\SRBackup
C:\ProgramData\Microsoft\Windows\AppRepository>move StateRepository-* C:\SRBackup
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd
The process cannot access the file because it is being used by another process.
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd-shm
The process cannot access the file because it is being used by another process.
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd-wal
The process cannot access the file because it is being used by another process.
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd
The process cannot access the file because it is being used by another process.
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd-shm
The process cannot access the file because it is being used by another process.
C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd-wal
The process cannot access the file because it is being used by another process.
0 file(s) moved.
Can you offer any insight on what other steps I can take?
@Patrick: Two new commands have been added. Please run them from the beginning.