Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio pre-build scripts can't find exe files in windows/system32 [closed]

Tags:

I'm stumped. All of a sudden Visual Studio cannot find exe files in the Windows/System32 directory (such as xcopy, attrib etc).

I have some pre-build and post-build events that execute batch files that use xcopy and attrib. Previously they were working fine but today, during the build process, Visual Studio cannot find them. The error is shown: 'xcopy' is not recognized as an internal or external command, operable program or batch file.

When I first noticed the problem I tried running xcopy in a regular cmd prompt and the same problem occurred. After I restarted my computer, the problem disappeared in the regular cmd prompt but remained in Visual Studio. After the reboot, the problem does not occur in the Visual Studio cmd prompt either - only from within Visual Studio itself.

Everything appears normal if within one of the batch files I execute set to check the PATH variable or echo %systemroot%.

In the Tools->Options menu there are settings for VisualC++ directories. However I am running C#, not C++, and besides, I never changed these settings and they appear to be correct.

Anyone had this problem before? Thoughts?

like image 341
cbp Avatar asked Nov 04 '09 05:11

cbp


1 Answers

I encountered the same problem earlier when trying to build from Visual Studio.

Tried running XCOPY manually and it was failing with the message "xcopy' is not recognized as an internal or external command, operable program or batch file"

So I tried manually navigating to C:\WINDOWS\SYSTEM32 and executed XCOPY. It worked!

Solution:

  1. Navigate to Control Panel -> System -> Advanced System Settings -> Environment variables

  2. When windows is first installed that variable is: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

    Put these at the beginning of the PATH variable and click OK twice.

You will need to restart running applications to apply the new path to them, not the system.

like image 170
dopplesoldner Avatar answered Nov 15 '22 06:11

dopplesoldner