0

I have a batch file that copies Unrar.exe. But when I run it, it says: The system cannot the file specified. But when I check the path, it is correct. Here's my code:

if exist %ProgramFiles%\WinRAR\Unrar.exe copy /y %ProgramFiles%\WinRAR\Unrar.exe %cd%\Unrar.exe >nul

Why is this saying The system cannot the file specified?

1 Answer 1

0

%ProgramFiles% refers to 'C:\Program Files' folder. On command line paths containing spaces must be enclosed between quotation marks. For ex.

%ProgramFiles%\WinRAR\Unrar.exe should be written as "%ProgramFiles%\WinRAR\Unrar.exe"

I also noticed %cd% variable, you better check if this variable refers to a valid path.

1
  • @Sekan BAYKAL Yes, %cd% is a variable, it refers to the current path. Try typing echo %cd% into cmd.exe.
    – BrickMan
    Commented Jun 24, 2019 at 16:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .