14

cmd.exe is not in the directory C:\Windows\System32. I think that I accidentally deleted it while messing with the environment variables, I don't know.

It's not launching from PowerShell, and I also tried Run (Win + R), but it still doesn't work.

I think reinstalling Windows is an option, but I don't know what can happen.

I'm using Windows 10.

How can I recover/restore cmd.exe?

8
  • 4
    copy cmd.exe from another W10 PC. – Moab Mar 21 at 21:17
  • 15
    @Paul I'd be hesitant to download Windows components from 3rd party sites when a known good copy can most likely be restored with built in tools – gronostaj Mar 22 at 19:16
  • 2
    @gronostaj the links are to Microsoft servers, e.g. latest version of Windows 10 2004: msdl.microsoft.com/download/symbols/cmd.exe/E1CBFC5367000/… – Paul Mar 22 at 19:19
  • 4
    @Paul That is an answer, and should be posted as such. Now we cannot vote on it, but we can write comments like: Ideally, we would not worry about where we download software from, but rather perform verification on the download itself. But that is not really an option for the average user. Verifying URLs is not really an option for the average user either, despite extraordinary efforts at education over many years. That is, the average user cannot be trusted to verify that the m417z site actually links to Microsoft’s site. And even if that site is legitimate today, it might not be tomorrow. – Brian Drake Mar 23 at 10:21
  • 5
    @Paul Obviously, when you post this as an answer, you should label the link as an example, explain the idea of downloading files from sites like this, and include the sort of warning that gronostaj and I are looking for. – Brian Drake Mar 23 at 11:44
50

You can run the System File Checker tool (SFC.exe) which will repair missing or corrupted system files:

  1. Open PowerShell as administrator.
  2. Enter sfc /scannow.

From Microsoft:

The sfc /scannow command will scan all protected system files, and replace corrupted files with a cached copy that is located in a compressed folder at %WinDir%\System32\dllcache. The %WinDir% placeholder represents the Windows operating system folder. For example, C:\Windows.

1
  • See the provided link for even more details on sfc. – MendelG Mar 22 at 12:46
8

If it was not deleted too long ago, you can retrieve it from a windows restore snapshot. Open Explorer, go to the properties of the folder C:\Windows\System32 (via the right-click menu), and go to "Previous Versions", from which you can open any snapshot of that folder. Snapshots that were taken before a file was deleted would contain that file.

2
  • 1
    An advantage of this method is that it works for all files that were accessible using Explorer, way beyond just system files. – user21820 Mar 23 at 12:30
  • 1
    IF windows restore was enabled that is. But if it is: safest and easiest solution possible – Hobbamok Mar 24 at 13:52
7

As requested in the comments, I'm posting this as an answer:

There's a website called Winbindex that provides links for Windows 10 binaries. The links are to Microsoft servers, so you don't need to trust a third party service as long as you verify that the links lead to Microsoft servers (if you don't know what that means, I don't recommend to use the service).

For example, here are various cmd.exe versions to download: https://winbindex.m417z.com/?file=cmd.exe

All links lead to msdl.microsoft.com, for example: https://msdl.microsoft.com/download/symbols/cmd.exe/E1CBFC5367000/cmd.exe

9
  • 3
    “you don't need to trust a third party service” You need to trust that Winbindex, a third party service, still points to Microsoft servers when you access it. Alternatively, you can verify every link before using it, but bitter experience has shown that the average user cannot be trusted to do this. – Brian Drake Mar 23 at 11:54
  • 3
    It's exactly as @BrianDrake says. History has proven to us time and time again that 'good' people/sites can go real bad with no warning. Such as AdBlock white-listing paid ads, NoScript showing ads for malware, PDFCreator downloading malware, and so on. And even that knowledge is not necessary to know that your statement "you don't need to trust a third-party service" is FALSE simply because winbindex.m417z.com IS a third-party service. – user21820 Mar 23 at 12:28
  • 1
    I added a clarification about trusting this service and verifying the links – Paul Mar 23 at 12:48
  • 3
    @AndrewLeach You're technically correct, but every website is a third-party site. If someone has superuser.com open in their browser then they're (consciously or not) accepting that risk. – gronostaj Mar 23 at 14:07
  • 1
    @NotThatGuy This is not a complete list: I live in Australia, so if they were targeting me, they might try msdl.microsoft.com.au. I am guessing that Microsoft actually controls that domain, but how can I be sure? This is why I have repeatedly commented that link verification needs to be left to security experts; everyone else should simply avoid sites like this. I think the current warning is good, but does not go far enough. – Brian Drake Mar 24 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.