xcopy is not recognized as an internal or external

2020-06-30 04:11发布

I have a problem using 'xcopy' command.

I'm building a C# project with msbuild. At the end of the build, a batch file is called to copy my assemblies from Debug/Release to some other folders.

Here is the problem, my build fail and the error log is 'xcopy is not recognized as an internal or external command, operable program or batch file'.

The path is correctly set, xcopy do works from a windows command line and from the visual studio command line (the one set with the project environment).

I tried to set the path in the batch file but it doesn't help.

Any suggestion?

I'm using windows 7

Cheers :)

标签: xcopy
8条回答
成全新的幸福
2楼-- · 2020-06-30 04:47

Go to environment variable and correct PATh including ; in last. It will work, this is not at all related to OS or Technology. It's working for me, Not even need to restart OS, Just open new command prompt.

查看更多
冷血范
3楼-- · 2020-06-30 04:48

It happened to me after I updated one of my Visual Studio extensions, during which Visual Studio was closed and reopened by the updater. I could no longer properly build my project. I closed Visual Studio and reopened it and the problem went away.

查看更多
Deceive 欺骗
4楼-- · 2020-06-30 04:50

I encountered the same problem.

It seems to be a problem with the path environment variable within Visual Studio.

When I added a "path" statement to the beginning of my build event, it produced the following output:

PATH=

This seems to indicate that the path is empty within the VS build environment.

When I specify the full path to xcopy like this, the problem went away:

%systemroot%\System32\xcopy ...

I'm not sure what caused Visual Studio to lose it's path.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2020-06-30 04:54

Set Environment variable PATH = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

查看更多
Viruses.
6楼-- · 2020-06-30 04:56

I just experienced this for the first time with a batch file I use to copy an Access front-end app to the user's local machines. Their environment is a mix of Windows 7 & 8 and 32-64 bit machines. I noticed that the xcopy.exe was both in the System32 and the SysWOW64 folders and I wondered if there was some conflict. So -- I copied the xcopy.exe into the folder where the batch file resides and it now seems to be working. Just thought I'd share this.

Eileen

查看更多
相关推荐>>
7楼-- · 2020-06-30 04:58

[Fixed for me] After adding the correct paths to "Path" environmental variable it still doesn't work (for cmd and VisualStudio) (even after restarting the PC).

The problem was in broken register parameter: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment] ParameterName=PATHEXT

I had the value .wlua;.|exe. Maybe was broken after installing something. Everything works again after changing it to: .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

Hope this helps if nothing other works.

查看更多
登录 后发表回答