2

I'm executing the following command:

xcopy /Y /R "%VS140COMNTOOLS%..\IDE\CommonExtensions\Platform\DiagnosticsHub\x86\dbghelp.dll" binaries\msvcr\

This command results in the following:

File not found - dbghelp.dll
0 File(s) copied

echo %VS140COMNTOOLS% yields the following - I merely expanded the environment variable:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\

Meanwhile, the following command works:

 xcopy /R /Y "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\..\IDE\CommonExtensions\Platform\DiagnosticsHub\x86\dbghelp.dll" binaries\msvcr\

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\..\IDE\CommonExtensions\Platform\DiagnosticsHub\x86\dbghelp.dll
1 File(s) copied

What's the problem?

Mofi
  • 38,783
  • 14
  • 62
  • 115
Violet Giraffe
  • 29,070
  • 38
  • 172
  • 299

1 Answers1

1
xcopy /Y /R "%VS140COMNTOOLS%..\IDE\CommonExtensions\Platform\DiagnosticsHub\x86\dbghelp.dll" binaries\msvcr\

The command line above fails with the error message below in 4 cases:

File not found - dbghelp.dll
0 File(s) copied

  1. The folder path assigned to environment variable VS140COMNTOOLS does not end with a backslash.
    This possible cause of error is obviously not the case here as echo %VS140COMNTOOLS% prints the folder path with a backslash at end.

  2. The environment variable has the string value:
    %ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Tools\
    But this is not the case here as otherwise echo %VS140COMNTOOLS% would print that string.

  3. The folder path assigned to environment variable VS140COMNTOOLS has 1 or more trailing spaces/tabs.

  4. The folder path assigned to environment variable VS140COMNTOOLS starts with 1 or more leading spaces/tabs.

For the second and third cause of error it would help to run echo "%VS140COMNTOOLS%" and look if the output is:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\ "

or

" C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\"

Using syntax set variable=value can easily result in getting the value with trailing spaces/tabs assigned to the environment variable resulting on usage in errors like this one. The solution is using set "variable=value" as explained in detail in answer on Why is no string output with 'echo %var%' after using 'set var = text' on command line?

For completeness a definition of the environment variable VS140COMNTOOLS with the command line

set VS140COMNTOOLS="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\"

with first double quote after equal sign instead of left to variable name and no trailing spaces/tabs would result in execution the command line:

xcopy /Y /R ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\"..\IDE\CommonExtensions\Platform\DiagnosticsHub\x86\dbghelp.dll" binaries\msvcr\

But this command line would result in the error message:

Invalid number of parameters

So already double quoted folder path can be also excluded as possible cause of the error.

BTW: The help of xcopy output by running in a command prompt window xcopy /? lists the optional parameters after source and target parameters. It is of course possible to specify first /R /Y and then source file and target folder, but it is in general advisable to use the syntax as suggested by help of command.

Community
  • 1
  • 1
Mofi
  • 38,783
  • 14
  • 62
  • 115
  • Great answer, but it doesn't actually solve the problem, sadly. `echo "echo %VS140COMNTOOLS%"` produces `"echo C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\"`. – Violet Giraffe Jan 23 '17 at 18:44
  • That's very strange. I suggest next to use free tool [Process Monitor](https://technet.microsoft.com/en-us/sysinternals/processmonitor) from Sysinterals (Microsoft) with filter set to __Path contains dbghelp.dll__ then __Include__, run the command __xcopy__ with the environment variable reference and look in log of Process Monitor on recorded file system activities. – Mofi Jan 24 '17 at 05:53
  • Well this was fun. Just so happens that I'm mostly using PowerShell as my every-day terminal, and my command fails there. But it works in cmd.exe. This is on Windows 10. – Violet Giraffe Jan 26 '17 at 15:07