Windows System Command Line

Have you ever wondered why you can just type ipconfig into a command prompt and it works, but when you want to use a command line program you downloaded you have to navigate to its directory first? Here’s how to fix that using the Windows System PATH.

  1. Windows System Command Line
  2. System Restore Command Line Windows 10

What Is the Windows System PATH?

Advanced Tip How to use the SFC command utility to fix system files on Windows 10 If Windows 10 isn't working correctly, you can use the SFC command-line utility to repair corrupted or missing.

If you’ve downloaded a program for the Command Prompt–like ADB, the Android Debugging Bridge–you can’t just type adb in the Command Prompt to run it, like you can with Windows’ built-in commands (e.g. ipconfig ). Instead, you have to tell Command Prompt where to find that file, by typing in the full path of the EXE:

That’s a lot of typing, though, especially for something you have to run often.

Windows has command line utilities that show us the version of the Windows OS running on the computer, including the service pack number. There are multiple CMD commands that help with finding this, you can pick the one that suits your need. If the SFC command doesn’t work, you can also try the Deployment Image Servicing and Management (DISM) command on Windows 10 or Windows 8 to repair the underlying Windows system image. On Windows 7 and earlier, Microsoft offers a downloadable “System Update Readiness Tool” instead. Let’s take a look at how to use them. Run Windows Update from Command Line in Windows 10. Simply launch the Elevated command prompt in Windows 10. For that make right click on the Start button and from the WINX menu click Command Prompt admin. When UAC dialogue box appears, click to open it. Check this post to find out different ways on how to launch the Elevated command prompt.

The Windows System PATH tells your PC where it can find specific directories that contain executable files. ipconfig.exe, for example, is found in the C:WindowsSystem32 directory, which is a part of the system PATH by default. When you type ipconfig into a Command Prompt, Windows doesn’t need to know where that EXE is–it’ll check all the folders in its PATH until it finds the right one.

Windows System Command Line

In a previous blog I explored two ways to launch a command prompt in Windows as the System user. Since I jumped on the Windows 10 bandwagon, slept on the sidewalk to be the first one in my neighborhood to have it, I wondered if the methods mentioned in that blog would work in Windows 10. Microsoft Windows Server instructions on how to get Windows Server system information from the. Information about a local or remote machine from the command line. Here is how to open Command Prompt in Windows 10, 8, 7, Vista, and XP. You have to open the Command Prompt in Windows before executing a command.

If you want the same convenience with a program you downloaded (like ADB), you need to add its folder to Windows’ system PATH. That way, when you need to run adb, you can just run:

No extra typing necessary.

How to Add a Folder to Your PATH

RELATED:How to Install and Use ADB, the Android Debug Bridge Utility

The first several steps of the process are the same for Windows 7, 8, and 10. Start by pressing the Windows key to open up the Start Menu or Start Screen, then search for “advanced system settings.” You can alternatively browse through Control Panel to System and Security > System and click on the Advanced system settings hyperlink in the left hand pane.

Once the System Properties window opens, click on the “Environment Variables” button.

In the “System Variables” box, look for a variable called Path. Select that and click on the “Edit” button.

This is where things are different between the versions of Windows—it’s the same for 7 and 8, but slightly different (and easier) in Windows 10.

In Windows 7 and 8

In 7 and 8, the variable value for Path is nothing more than a long string of text with various locations around the system. We’ve put the ADB executables in C:Androidplatform-tools on our machine, so that’s the location we’re going to add.

In order to add an entry to your path in Windows 7 and 8, you have to precede the folder with a semicolon, like so:

Add that exact line at the end of the variable value (make sure not to delete any of the existing text in the value!) without a space. Click OK, and you’re done. Simple.

In Windows 10

In Windows 10, this process is both easier and less confusing. Once you’ve clicked the edit button, a new dialog box will appear with each location in the path on a separate line. This is a dramatic improvement over the way previous versions of Windows handled path locations, and makes easy work of adding a new one.

First, click the ‘new’ button, which will add a line at the end of the list. Add your location— C:Androidplatform-tools in our example—and hit Enter. There is no need to add a semicolon like in Windows 7 and 8. Click the “OK” button and you’re finished.

The Android Debugging Bridge should now be accessible from any command prompt, no need to specify its directory.

READ NEXT
  • › Confirmed: Windows 10 Setup Now Prevents Local Account Creation
  • › How to Disable the Apple Watch’s Always-On Display
  • › How to Back Up Your Stuff and Switch to a New Mac
  • › Is the Mac Pro Overpriced Compared to a PC?
  • › Just Bought a Mac? 14 Essential Apps You Should Install

When you begin to notice random errors, issues during boot or Windows components are not working as they should on your computer there is a good chance that one or more system files may have gone missing or corrupted.

Golden state killer. Rosewood, Jack (2015).

Even though Windows 10 does a good job protecting files that are necessary for your PC to work correctly, applications, drivers, or even Windows Update may sometimes be the cause of system instability. Like in previous versions, for these situations, Windows 10 includes the System File Checker (SFC), a tiny but powerful command-line utility that can scan the integrity and replace any corrupted or missing protected system file with a known good version.

In this guide, we'll walk you through the steps to use System File Checker (SFC) to repair any damaged system file automatically while you're running the operating system, offline using Advanced startup, and manually when SFC is unable to fix the problem.

Before you begin, it's important to note that you'll be making changes to your system, as such it's recommended to do a full backup or create a system restore point in case things go wrong, and you need to roll back.

How to scan and repair system files on Windows 10

The following command will do a full scan of the protected system files on your computer and fix any file that are causing issues while Windows 10 is up and running.

  1. Use the Windows key + X keyboard shortcut to open the Power User menu and select Command Prompt (Admin), as you will need administrator permissions to run SFC.
  2. In the Command Prompt type the following command and press Enter:

    sfc /scannow

  3. Once the scan completes, you will see one of the following messages:

    • Windows Resource Protection did not find any integrity violations: This indicates that your system doesn't have any missing or corrupted files.
    • Windows Resource Protection could not perform the requested operation: This message means that there was a problem during the scan and an offline scan is required.
    • Windows Resource Protection found corrupt files and successfully repaired them. Details are included in the CBS.Log %WinDir%LogsCBSCBS.log: You will get this message when SFC was able to fix the problem. Now, you can move on or you can view the logs to get more details.
    • Windows Resource Protection found corrupt files but was unable to fix some of them. Details are included in the CBS.Log %WinDir%LogsCBSCBS.log: In this case, you'll need to repair the corrupted files manually.

Quick Tip: You may want to run the command around three times to fix all the problems.

How to view the details of an SFC scan

To see the details of a System File Checker stored in the CBS.Log file, you'll need to make a readable copy on your desktop:

  1. Use the Windows key + X keyboard shortcut to open the Power User menu and select Command Prompt.
  2. Type the following command and press Enter:

    findstr /c:'[SR]' %windir%LogsCBSCBS.log >'%userprofile%Desktopsfclogs.txt'

  3. Open the sfclogs.txt located on the desktop with Notepad. The file will contain all the details of the scanned system files and information for files that couldn't be repaired.

Note: Details for SFC scans are only available when you do a scan within Windows, not when you do an offline scan on Command Prompt.

How to scan and repair system files on Windows 10 offline

Windows System Command Line

Sometimes protected system files that need to be repaired are loaded in memory while Windows 10 is running. If this is the case, you can run SFC offline to fix your computer.

  1. Use the Windows key + I keyboard shortcut to open the Settings app.
  2. Click Update & security.
  3. Click Recovery.
  4. Under Advanced startup, click Restart now.

  5. Click Troubleshoot.
  6. Click Advanced options.
  7. Click Command Prompt to boot your computer only with Command Prompt.

  8. On reboot, you'll be prompted to enter your username and password to continue.
  9. Whenever you need to run SCF outside of Windows, you need to tell the utility exactly where the Windows installation files are. On Command Prompt, type the following command to understand the location of the Windows and System Reserved partitions.

    wmic logicaldisk get deviceid, volumename, description

  10. Type the following command, and press Enter:

    sfc /scannow /offbootdir=C: /offwindir=D:Windows

    Note: We're using the /offboodir switch to specify the drive letter of the System Reserved partition, which in this case is C, and the /offwindir switch specifies the location of the Windows files, which in this case is D:Windows.

    Keep in mind that when you boot your computer with Command Prompt, the drive letters may be different, which is why you need to use the command on step 9. However, most of the time, when working with Windows 10, D: is usually the drive letter for the installation and C: is the letter for the System Reserved partition.

  11. Once the scan is complete, close Command Prompt.

  12. Click Continue to exit and go back to Windows 10.

How to repair system files manually on Windows 10

If the System File Checker couldn't fix one or more files, you will need to repair them manually.

Open the sfclogs.txt file to determine which are the corrupted files, find where they belong by doing a simple file search or use your preferred Internet search engine to get more details. Then follow the instructions below to replace the corrupted file.

Quick Tip: You can find known good system file copies on another computer running the same version of the operating system like the one running on your PC.

  1. Use the Windows key + X keyboard shortcut to open the Power User menu and select Command Prompt (Admin).
  2. Take ownership of the corrupted system file. In the Command Prompt type the following command, and press Enter:

    takeown /f C:Path-and-File-Name

    Note: Replace C:Path-and-File-Name with the path and name of the corrupted file. For example, C:WindowsSystem32appraiser.dll.

  3. Allow full admin access to the corrupted file using the following command and press Enter:

    icacls C:Path-and-File-Name /Grant Administrators:F

  4. Replace the file in question with a good copy using the following command and press Enter:

    copy C:Path-SOURCE-and-File-Name C:Path-DESTINATION-and-File-Name

    Note: You need to replace C:Path-SOURCE-and-File-Name with the source path and file name of the known good file, and you also need to replace C:Path-DESTINATION-and-File-Name with the destination path and name of the damaged file. Here's an example: copy D:Filesappraiser.dll C:WindowsSystem32appraiser.dll.

  5. Type Yes and press Enter to confirm the overwrite.

System Restore Command Line Windows 10

After replacing the file, you can type SFC /verifyonly command and press Enter in Command Prompt to verify the integrity of all the system files to see if the problem has been fixed. Alternatively, if you repaired only a few files, you can test the integrity of each file by using the sfc /VERIFYFILE=C:Path-and-File-Name command (e.g., sfc /VERIFYFILE=C:WindowsSystem32kernel32.dll).

Keep in mind that you're not limited to use this utility on Windows 10, SFC is a command-line tool available on previous versions of the operating system. However, you may find different features depending on the version you're running. In Command Prompt (Admin) use the sfc /? command to list the features available to you.

More on Windows 10

For more tips, coverage, and answers on Windows 10, you can visit the following resources: