How To Repair Missing Or Corrupt Windows Files From The Command Prompt

by Codrut Neagu published on 02/19/2015. digitalcitizen . life

When you have problems with your computer, Windows system files may become corrupted or go missing. This might be caused by all kinds of issues like sudden power drops, hardware malfunctions, a hard disk approaching its “death” and so on. If Windows reports that it cannot start because some of its files are corrupted or missing, you should use the System File Checker (SFC) tool in the Command Prompt. You should do the same when Windows starts to Blue Screen on you with weird corruption related errors. SFC scans all the Windows system files on your computer, identifies those that are corrupt or missing and tries to fix the problems it find. Here’s how to use it:

NOTE: This tutorial applies to both Windows 7 and Windows 8.1.

How To Fix Problems With Missing Or Corrupted Files When Windows Won’t Boot

If Windows doesn’t load because of missing or corrupt system files, follow this tutorial to start the Command Prompt: How To Start The Command Prompt When Windows Doesn’t Boot?.

In the Command Prompt window, use the sfc command with two additional parameters:

  • /offbootdir – used to specify the partition that contains the system files that are required for booting Windows. In most cases, this partition is going to be “C:\”.
  • /offwindir – used to specify the location of the Windows directory. In most cases, this folder is “C:\Windows”.

You will need to type something like: 

sfc /scannow /offbootdir=c:\  /offwindir=c:\windows and press Enter.


The “translation” for this command is the following: scan the Windows folder located on the boot partition “C:\”and fix missing or corrupt system files.

Arm yourself with some patience because running this command will take quite a bit of time. When the process finishes, you are informed that the verification is 100% complete. If problems were found, you are also informed. The problematic files that cannot be fixed are always mentioned in a log file named CBS.log. This file is found in the Windows folder, at this location: “C:\Windows\Logs\CBS\CBS.log”.

If everything is fine with your system files, you will receive a message saying that: “Windows Resource Protection did not find any integrity violations”.

How To Fix Problems With Missing Or Corrupted Files When Windows Boots

You may also find yourself in a scenario where Windows loads successfully but it crashes randomly with a Blue Screen of Death (BSOD) mentioning corruption errors. If that is the case for you, start the Command Prompt as an administrator, using any of the methods described in this tutorial: 7 Ways to Launch the Command Prompt in Windows 7 & Windows 8.

Type the command: sfc /scannow and press Enter. The /scannow parameter forces the SFC tool to scan the integrity of all system files and repair problematic files when possible.


Again, arm yourself with some patience. The tool takes a long time to run. At least a couple of minutes. When it’s done, you are informed that the verification is 100% complete. If problems were found, you are also informed.

In our case, SFC found corrupt files and it was unable to fix some of them.


The problematic files that cannot be fixed are always mentioned in a log file named CBS.log. This file is found in the Windows folder, at this location: “C:\Windows\Logs\CBS\CBS.log”.

How To Analyze The CBS.Log File

Go to “C:\Windows\Logs\CBS” and open the CBS.log. This file is quite large and it takes a while to open it in Notepad. If possible, open it with a different application like Notepad++ or Microsoft Word, so that it is opened faster and you have an easier time working with it.


Scroll towards the end of the file and search for entries that start with the text: “Cannot repair member file”. There you will find the missing or corrupted system file(s) that cannot be repaired.


Search for information online about the file(s) mentioned in this log file and from there on you might get an idea on how to fix your problems.


Hopefully you will never need to use the SFC command to repair Windows systems files. However, if you do have issues, don’t hesitate to consider using it. This tutorial should come in handy when you have to deal with system files being corrupted or missing.

If you are looking for other useful troubleshooting tutorials, read the articles recommended below.


How to use the Command Prompt to fix issues with your PC’s boot records

by Codrut Neagu published on 02/02/2017. digitalcitizen . life

You can use system recovery tools to fix most of your computer problems. However, there are times when you’ll need to address such issues in a manual way, like, for example, when your Windows computer won’t boot. In these cases, you can use a tool named Bootrec.exe. It can help you troubleshoot and repair things like the Master Boot Record (MBR), the boot sector or the Boot Configuration Data (BCD) store. Here’s how it works, in all modern versions of Windows:

NOTE: This guide covers Windows 10, Windows 7 and Windows 8.1.

Bootrec.exe – The ultimate repair tool for boot problems in Windows

No matter whether you use Windows 7 or Windows 10, if your operating system has trouble booting and Startup Repair can’t fix the problem, it’s worth trying the Bootrec.exe tool. With this tool you can repair the Master Boot Record (MBR), write a new boot sector, rebuild the Boot Configuration Data (BCD) and add missing Windows installations to the boot configuration data.

If you need to know what all these mean, here’s an explanation for each of them:

  • Master Boot Record (MBR) – the first sector of your system drive. Its purpose is to tell the computer’s BIOS where to look for the operating system, so that it can start it.
  • Boot Sector – the region of the disk that contains the code to be loaded into the RAM memory, that is necessary to load the operating system. A boot sector must have a specific disk signature to be seen by BIOS as a boot sector. If this signature is corrupted, or has been changed, the BIOS will not be able to find the boot sector and won’t be able to load the necessary instructions for finding and starting the operating system. In Windows 7 and newever versions of Windows, the boot sector loads the Windows Boot Manager, accesses the Boot Configuration Data and uses this information to load the operating system
  • Boot Configuration Data (BCD) – The BCD is a database of boot-time configuration data that is used by the Windows Boot Manager. The Boot Configuration Data is stored in a data file that has the same format as the Windows Registry.

How to start the Command Prompt when Windows won’t load successfully

In order to be able to use Bootrec.exe, you’ll have to use Command Prompt. However, because you already have startup issues, it’s obvious that you won’t be able to simply run it from Windows.

You need to use a repair disc or a recovery drive that was created on a working Windows computer. Here are some guides that will help you create such discs/drives:

  • What is a system repair disc and how to create one in Windows – this guide applies to all modern versions of Windows. Windows 7 users can only use this method if they want to have a chance at repairing the computer. The repair disc can be a CD or DVD with all the necessary files for troubleshooting your system
  • How to create a recovery drive in Windows 10 – learn how to create a bootable USB memory stick with recovery tools for Windows 10.
  • How to create a recovery drive on a USB memory stick in Windows 8 & 8.1 – this guide is useful for Windows 8 users only.

Once you have recovery drive/disc created, boot from it. In order to do that, plug it in and start your Windows computer or device. Immediately after it starts, press the boot device selection key on your keyboard. It’s usually the F12, F11 or the Escape key, but it could be another as well, depending on the manufacturer of your device’s mainboard. Doing that will make your computer display a boot priority selection menu. Use the arrow keys on the keyboard to select the recovery drive. Then, press Enter and, when asked to press any key to boot from that drive, do so.


If you are using Windows 10 or Windows 8.1, once your PC boots from the USB drive, you will be asked to choose the keyboard layout that you want to use. When this happens, click or tap on the layout that matches your keyboard. To navigate between all the available keyboard layouts, press “See more keyboard layouts”.


The list of available keyboard languages is quite long and you may have to scroll a lot until you find the layout that you want to use. On the next screen, you should click or tap on Troubleshoot (Reset your PC or see advanced options).


On the Advanced options screen, click or tap on Command Prompt.


If you are using Windows 7, first, select the keyboard input method that you want to use and click Next.


Then, it scans for available Windows installations and lists those that are found. Select the Windows 7 installation that you want to repair and click Next.


Then, when the list of available System Recovery Options are shared, click Command Prompt.


Once you’ve launched the Command Prompt, type the command bootrec.exe and hit Enter to see the options that are available for this tool. As you can see in the screenshot below, there are four parameters available: /FixMbr, /FixBoot, /ScanOs and /RebuildBcd.


Let’s see how each of them can help you solve your computer’s boot problems. Keep in mind though, that even if the Bootrec.exe tool can handle most boot problems, it does not guarantee success in every possible situation.

How to repair the Master Boot Record (MBR)

The first parameter of the Bootrec.exe tool is /FixMbr. It allows the repair of a corrupted or damaged Master Boot Record (MBR). Usually, you will use this parameter when you are faced with one of these error messages: “Operating System not found”, “Error loading operating system”, “Missing operating system” or “Invalid partition table”. To start the repair process of the MBR, run the command: bootrec.exe /fixmbr.


How to write a new boot sector

The /FixBoot parameter writes a new boot sector to the system partition. The tool will use a boot sector that is compatible with your Windows version. Using this parameter is useful in the following situations:

  • The boot sector has been replaced with a non-standard Windows boot sector;
  • The boot sector is damaged;
  • An earlier Windows operating system has been installed after your version of Windows was installed.

To start writing a new boot sector, use this command: bootrec.exe /fixboot.


How to rebuild the Boot Configuration Data (BCD)

The Boot Configuration Data (BCD) contains a detailed list of what is supposed to load at startup. Microsoft indicates that a boot error can also be caused by missing or damaged files in the BCD. The /rebuildbcdparameter can be very useful when you must fix some errors by completely rebuilding the BCD. To completely rebuild the Boot Configuration Data, run this command: bootrec.exe /rebuildbcd.


How to add missing Windows installations to the Boot Configuration Data

If your computer has multiple operating systems installed but not all of them are available, use the /ScanOSoption. Using this parameter on Bootrec.exe will launch a scan on all disks for any Windows installations that are not currently included in the Boot Configuration Data (BCD). In the screenshot below, you can see how this scan process might look.


If the bootrec.exe /scanos command returns results, you will be able to continue the repair process. In the end, you will get the lost Windows installation back into the secure BCD table, thus making it bootable again.


First of all, you have to clean the Master Boot Record (MBR) by using bootrec /fixmbr. Next, type bootsect.exe /nt60 all /force and press Enter. The /nt60 parameter applies the master boot code that is compatible with BOOTMGR. The /all argument updates the master boot code on all partitions. The /force parameter forcibly dismounts the volume(s) during the boot code update so that the Bootsect.exe tool does not gain exclusive volume access.


Running all these commands will create a new MBR and tell it to use the correct Windows boot loader in order to load that specific installation from your drive.


As you can from this guide, Bootrec.exe is a very powerful tool for troubleshooting and fixing problems with your Windows computer’s boot records. If you know other ways to fix issues with your boot records, don’t hesitate to share them in a comment.




Command Prompt – The Most Powerful & Least Used Windows Tool

by Codrut Neagu published on 12/06/2010. digitalcitizen . life

At the beginning of 2010, we started a series on system recovery tools for Windows 7. Little did we know that the series would expand tremendously and, in the end, we would cover quite extensively a very old and misunderstood tool: the Command Prompt. While working with it, we were fortunate to truly learn its power and usefulness. Therefore, we would like to end our series of articles with a recap about all the great things the Command Prompt can do.

The Basics about the Command Prompt

If you have not used the Command Prompt much, it is best to start with the basics. In our article about How to Customize the Command Prompt you will learn where to find this tool and how to start it and customize it. You might not think of your Command Prompt as something cute and colourful, right? Think again. Go through this tutorial and experiment with all the configuration options. The Command Prompt can be cute and pink too, right along with the newer, sexier Windows 7 tools such as Desktop Gadgets.

Before you run any command, it is best to learn how to run the Command Prompt in Administrator ‘mode’. Many of its powers require administrator privileges in order to work.

In Command Prompt – How to Use Basic Commands  we have covered the most basic and yet useful commands. You will learn how to navigate through partitions, files and folder structures and how to work with them. Also, you will learn how to launch other applications or how to get help while working in the Command Prompt.

Getting into Command Prompt’s Advanced Powers

Now that you’ve got your basics right, it’s time to fine-tune your ninja computing skills and learn some of the advanced commands you can run inside the Command Prompt:

  • Command Prompt – Advanced Disk Management Commands – To complete the list of file and folder management commands listed in the basic guide, we’ve got more advanced stuff about how you can manage your partitions directly from the Command Prompt. You will learn how to create, modify or delete partitions with a few simple commands.
  • Command Prompt – Advanced Commands for System Information & Managing Active Tasks – Do you want to know all currently running processes? Do you have an unresponsive application which you want to kill? Do you want complete system information by typing only one short command? This tutorial has the answers for you.
  • Command Prompt – Advanced Networking Commands – If you want to be the ultimate geek, you need to learn a bit about networking and how to run some networking tasks in the Command Prompt. This tutorial covers useful commands which help you retrieve information about your network connections and MAC address; and test and display information about active connections.

Repair Your Computer from the Command Prompt

The ultimate power users (such as geeks :)) are able to utilize the Command Prompt also for repairing broken computers and Windows operating systems. For them we’ve got the following tutorials:


Our series on the Command Prompt tool is far from being complete. We did not manage to cover all the commands you can run. What we tried to do was to simply give you a taste of what this powerful tool can do for you and hopefully raise your interest in learning more about it. Do let us know if we’ve succeeded. Also, if you’ve got some other cool tips and commands to share, don’t hesitate to leave a comment. We might decide to continue the series.


Command Prompt – 6 Disk Management Commands you should know

by Codrut Neagu published on 06/21/2016. digitalcitizen . life

One of the easiest and most straightforward ways to manage your disks is to use the Disk Management tool from Windows. But hey, Disk Management is a visual tool and some of us like command based interfaces a whole lot more. That’s why we thought it would be a great idea to see how several disk management actions can be done from the Command Prompt , using DiskPart and other command-line tools . In this article you will learn how to create, format, delete, defragment and check your partitions for errors, directly from the Command Prompt . Let’s get started:

Important aspects to consider before moving forward

In order to perform any action presented in this article, you need to have administrative permissions and run the Command Prompt as administrator. Check ou t 7 Ways To Run Programs As Administrator In Windows to see how to run Command Prom pt as administrator.

It’s also very important for you to acknowledge the fact that, if you misuse the commands listed in this article, you risk losing your data. Be careful and make a backup of your data before going ahead. If anything bad should happen, don’t say we didn’t warn you! 🙂

1. How to create a partition from Command Prompt

First of all, open the Command Prompt. Then, type diskpart to access the Windows tool called Diskpart .


After you’ve launched diskpart it’s time to establish which hard drive or solid state drive will be used to create a new partition. You will select the drive by using the select command. To view the available disks on your system, use the command list disk.


To select the disk you want to work with, type select disk followed by the number of the hard disk you want to use.


To create a new partition, you need to use the create partition command followed by the partition type and size. Note that the list command used previously also displays the available free space on each hard disk. Your partition must be of a size equal or less to the amount of available free space.

For instance, in order to make a new primary partition with the size of 1000 MB, you should type “create partition primary size=1000” . Use the same command and change the size according to your needs and the available free space on your hard disk.


2. How to assign a letter to a partition from Command Prompt

You can and will probably want to also assign a letter to the newly created volume. Assigning a letter to a partition makes it visible in File Explorer , so that you can easily access it. To assign a letter to a partition directly from Command Prompt , use the assign command.

For instance, if you wanted to assign the R letter to the partition you just created, you should type “assign letter = R” .


Please remember that before assigning a drive letter, you need to start Diskpart and select the disk for which you want to assign the letter.

3. How to format a partition from Command Prompt

Although you now have a new partition created on your computer or device and it also has a letter assigned so it’s easy to access it, you are still unable to use it until you also format that partition. To do that too, use the command “format fs=ntfs quick” . Use help format to find out more information about this command.


This command should be used after you start Diskpart and select the disk that you want to format.

When you are done working with diskpart , type the exit command to close the program.


4 . How to delete a partition from Command Prompt

When you need to delete a drive from your computer, the procedure is quite simple. First, open the diskpart application. Then, select the partition that you want to delete and type the delete partition command. You can see an example of how the delete operation works, below. It is a matter of selecting the disk where the partition is found, then selecting the volume to be deleted and running the delete command.


5 . How to check a disk for errors from the Command Prompt

To check a disk for errors you have to use the chkdsk command. Type chkdsk followed by the drive’s letter. We recommend that you always use this command in combination with the /f parameter. This enables the tool to automatically fix any errors it finds.

As an example, we will scan the R : drive for errors by typing chkdsk /f r: and pressing Enter . The scan process will start.


After the scan is finished you see a report similar to the one from the picture below.


This summarizes how much disk space the partition has, how many files are in use by the system, how much free space is available on the disk, how many bad sectors were identified and so on.

6 . How to defragment a disk from the Command Prompt

The Command Prompt also gives you a way of defragmenting a partition. All you have to do is type the command defrag followed by the drive’s letter. If you wanted to defragment the R: partition, for example, you would use “defrag r:”. If everything worked well, you should get a report like the one below, after the volume you selected has been defragmented.


The report includes information prior to the optimization process and after it was completed, like the volume size, free space, total fragmented space and the largest free space size.


Despite the fact that you might think it’s hard to manage your partitions through the Command Prompt , we hope that we managed to prove that it’s not that difficult. The procedures involved are not complicated at all and, once you know the correct commands, using the Command Prompt can be a lot faster than using other tools like Disk Management . If you have any questions, feel free to leave a comment below.



How To Make The Command Prompt Look & Work Better

by Codrut Neagu published on 09/14/2015. digitalcitizen . life

We like the Command Prompt and we are not alone in that. But, even though it is a mighty and powerful tool, it sure looks boring. What if you want to make it prettier? And what about customizing certain things about the way it works, like how many commands it stores in its history? To learn all this and more, read this tutorial.

NOTE: This article applies for Windows 7, Windows 8.1 and Windows 10.

What Is The Command Prompt?

Before Windows was created, the most used operating system was DOS (Disk Operating System). It was a text-based operating system, that allowed you to run programs by manually typing in commands.

The launch of the Windows operating system simplified the whole computing experience by making it more visual. Even though DOS is no longer included in Windows operating systems since Windows ME (in 2000), we still have the Command Prompt – the text command-line interpreter, analog of the command shell found in the old DOS operating system.

This tool is generally used by geeks and more advanced users, such as system administrators. With it, you can run all kinds of commands. You can manage your partitions, network devices and connections or you can simply run programs and executable files.

Most probably, the Command Prompt will be phased out and, in the future, Windows users will have to learn and use PowerShell if they want to use a powerful command line interpreter. But, for now, let’s see how to launch Command Prompt and how to make it look pretty. It is not as un-customizable as you would think.

How To Start The Command Prompt

This has been shown in detail, in this tutorial: 7 Ways to Launch the Command Prompt in Windows.

When you first open the Command Prompt it opens at your user folder: “C:\Users\Your user name”.


When you run it as administrator, it opens at the default system folder: “C:\Windows\system32”.


How To Access The Properties Of The Command Prompt

If you want to customize the way Command Prompt looks and works, you need to access its Propertieswindow. Right click or long press on the top of the Command Prompt window and select Properties.


You will notice four tabs with options that can be configured in detail: Options, Font, Layout and Colors.


Let’s take a look at these tabs and see what they offer in terms of customization options.

How To Customize The Command Prompt Cursor Size, Buffers And Edit Modes

The first tab is named Options. In Windows 7 and in Windows 8.1, it includes three sections: Cursor Size, Command History and Edit Options.


In Windows 10, besides the Cursor Size, Command History and Edit Options section, you’ll also find two additional sections for Text Selection and Current code page, and an additional option called Use legacy console.


Regardless of the operating system you use, the first section – Cursor Size – is about changing the size of the cursor. You can choose one of the available options: Small, Medium or Large.

In the Command History section you can customize how many commands are retained in the command buffer. The buffer serves as a historical record of the commands you have executed. Use the Up and Downarrow keys to navigate through the previously entered commands.

The default value is 50 commands but it can be made as large as 999. The next option, “Number of Buffers”determines for how many concurrent instances of the Command Prompt you’re using separate buffers. For example if you change the value to three, you will be able to have up to three Command Prompt instances opened, each with its own buffer. The last option from this section, “Discard Old Duplicates”, allows Windows to remove duplicate command entries from the buffer.

Both in Windows 7, Windows 8.1 and in Windows 10, the Edit Options section offers options for QuickEdit Mode and Insert Mode. The first one allows you to use the mouse to cut and paste text to and from the Command Prompt window. The second – Insert Mode – has the same function as the Insert keyboard key: the cursor inserts a character at its current position, forcing all characters past it one position further. If Insert Mode is disabled, then when you type, what you’re typing overwrites any text that is present in your current location.

A sample of how QuickEdit Mode works can be viewed in the capture below. With the mouse, we selected the text for copying. We then pressed Enter and the text was copied to the clipboard.


You can then paste the selected text in any other program.

If you’re using Windows 10, the Edit Options section offers two more options for you to use: Enable Ctrl key shortcuts and Filter clipboard contents on paste. However, in order to be able to use these (and other) new options, you first have to uncheck the last feature from the Options tab: Use legacy console.


Once you’ve unchecked Use legacy console and relaunched Command Prompt, all the new features brought by Windows 10’s Command Prompt can be enabled.

Let’s go back to the Edit Options section from Windows 10’s Command Prompt. If you Enable Ctrl key shortcuts, Command Prompt will let you use a set of keyboard shortcuts like Ctrl + C or Ctrl + V inside it, which is something you couldn’t do in previous versions. We promise we’ll talk about all the new keyboard shortcuts you can use in Windows 10’s Command Prompt in a very soon to come tutorial.

The last option from the Edit Options section of Windows 10’s Command Prompt is called Filter clipboard contents on paste. If you enable it, whenever you paste content from the clipboard inside Command Prompt, tabs are automatically removed and smart quotes are converted to regular ones.

Going further, Windows 10’s Command Prompt includes a new section called Text Selection. Here, you have two options which you can set: Enable line wrapping selection and Extended text selection keys.

Enabling line wrapping selection enhances the way in which Command Prompt handles text selection. Previous versions of Command Prompt only allowed copying text from it in block mode. That meant that each time you pasted content from Command Prompt in a text editor you had to manually correct tabs, word wrapping etc. If you enable this option, Windows 10 takes care of all that, so you won’t have to correct the flow of text anymore.

If you enable Extended text selection keys, Windows 10’s Command Prompt will allow you to use a set of common keyboard shortcuts inside it. For example, you can use Shift + Arrow keys to select text.


Current code page is also a new section from Windows 10’s Command Prompt. This section doesn’t include any options for you to set: it only informs you about the character code you use.

How To Adjust The Font Used By The Command Prompt

In the Font tab you can select the size and Font used by the Command Prompt window. Also, you can use the window preview to see the effect of your settings before applying them.


The Size list displays several values for how large each character is. Then, in the Font list you can select one of the three available fonts.

How to Change the Command Prompt Window Layout & Size

The Layout tab has three sections where you can configure the size of the Command Prompt window. The available options are as follows:

  • Screen Buffer Size – use it to configure how many characters are displayed on a line in the Command Prompt window, by adjusting the Width value. The number of lines that are stored in memory, are adjusted using Height value;
  • Window Size – use it to select the Width and Height of the Command Prompt window;
  • Window Position – enables you to configure the Command Prompt’s window distance from the left and top edges of the screen. This can be done only if the “Let System Position Window” box is not checked;
  • Let System Position Window – if it’s checked, you won’t be able to configure the window position settings but you can drag and drop, or resize the Command Prompt window with the mouse. 


Next, let’s take a look at the final tab.

How To Set The Window Colors For The Command Prompt

The Colors tab is all about customizing the colors used by the Command Prompt. There are four items that can be customized:

  • Screen Text – use it to set the color of the text, in the Command Prompt window;
  • Screen Background – use it to choose the background color of the Command Prompt window;
  • Popup Text – use it to set the color of the text displayed in pop-up windows triggered by the Command Prompt;
  • Popup Background – use it to set the background color of the pop-up windows triggered by the Command Prompt.


If you’re using Windows 10, Command Prompt also lets you set its transparency. Underneath all the sections from its Colors tab, you’ll find a section called Opacity. Moving the slider from this section will let you change the transparency of the Command Prompt to the level you want. Note however, that this option is only available if you unchecked the Use legacy console setting from the Options tab.


When you are done changing your settings, all that remains to do is for you to click or tap OK to apply them.


As you can see from this guide, there are plenty of customization options that allow you to make the Command Prompt friendlier than it seems at first sight. If you are looking for other useful tips about the Command Prompt, don’t hesitate to read the articles recommended below.