Question

I want to ensure via my batch file that I have a robocopy installed on the system. does it possible to ask something like if robocopy..to know if it installed in the system that I on it.?

Was it helpful?

Solution

>nul 2>nul robocopy
if errorlevel 9009 (
    echo ROBOCOPY is not installed
) else (
    echo ROBOCOPY is installed
)


EDIT

Here is another alternative that is perhaps safer because it does not attempt to execute the program. It attempts to see if the program exists in the PATH. You must know the full name, including the extension, of the program.

@echo off
for %%F in (robocopy.exe) do if "%%~$path:F" neq "" (
  echo ROBOCOPY is installed
) else (
  echo ROBOCOPY is not installed
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top