The Linux Page

Run the Repair command in a MS-Windows console

Repair your Windows Installation

My MS-Windows 10 instance would not run properly anymore. Once booted, the login prompt worked as expected (yeah!) but once logged in, the OS would crash after a minute or two and show me the blue screen of death (BSoD).

I wanted to try a repair, so I looked into various websites, here I write what I ran so I can remember for next time (assuming it worked this time, at least).

dism /image:C:\ /cleanup-image /restorehealth

Most often, somehow, you seen people tell you to use /online as the first parameter. The fact is that your drive is not likely going to be online if you can't run Windows and need to restore it. I'm not too sure what that option is for, actually... Windows 10 shows the following error message when using /online and you booted through the repair utility:

Error 50 DISM does not support servicing Windows PE with the /Online option.

The process, once started properly, took a pretty long time. At least they have the decency of showing a percent done with a bar. It was really slow around 51% for me, but it did complete successfully.

Backing Up Your Data

If the dism command doesn't work, you can backup your data from this console since you have access the the C:\ drive and you can always plug a USB stick to your computer. That way you have your data and can then re-install MS-Windows from scratch.

On my end, I have two huge advantages:

  1. I put all my documents in my Documents folder.
  2. I don't use MS-Windows much so the total amount of data is really small (about 1Gb)

Of course, if you have a lot more data, it may be a difficult task. Now I hope that you make constant backups if you're using MS-Windows... and this backup in the console would only be for the last few files you updated in the last few days and may not have the latest backup. You could also open your computer and switch the hard drive so that way you install MS-Windows on a new drive and keep the other one as a backup (that's assuming the drive is not the actual culprit here).

To copy a whole directory tree under MS-Windows, you use the xcopy command. A few important options are the /E, /S, and /H:

xcopy /S Documents E:\Backup

The /S means that all files and directories are copied recursively. By default, empty directories are not copied. If you want the empty directories, use the /E. Similarly, the default behavior is to ignore hidden files. The /H forces MS-Windows to copy those files. If you're a developer and need your .git folder, you probably want to use both: the /E and /H options. Otherwise your backup will probably not work as expected.

If necessary (i.e. your Thumb drive is too small for all your data to fit), you can always copy some files on your USB drive, then back them up on another computer, and repeat. To do that safely, you want to dismount the USB drive each time. This can be done on the command line with:

C:\User\Me\Documents> diskpart
diskpart> list volume
diskpart> select volume <number>
diskpart> remove all dismount
diskpart> exit
C:\User\Me\Documents> _

The diskpart utility allows you to dismount a USB drive.

The list volume command gives you a list of volumes with their number. What you want to use is that number. This is where having a good naming convention of your USB drives is going to be magical. If you are not sure, you can always plug that drive in another computer that works and fix the name.

The select volume <number> command adds an asterisk in the list of volumes. So when you type list volume after that command, you'll notice which ones are selected.


The remove all dismount command safely unmounts your USB drive (all selected drives, really).

Re: Run the Repair command in a MS-Windows console

Windows Backup is the best tool to use to back up your data, and it works across Windows platforms. So if your on a Windows 7 machine, you can use the back tool to transfer sensitive files to the latest iterations of Windows 10 & 11. Otherwise, excellent writeup.