How can I restore Cmd.exe (Command Prompt) if it doesn't exist?
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
?
Solution 1:
You can run the System File Checker tool (SFC.exe) which will repair missing or corrupted system files:
- Open PowerShell as administrator.
- 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.
Solution 2:
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.
Solution 3:
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