xcopy is not recognized as an internal or external command, operable program or batch file - xcopy

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 :)

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.

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

This is not a problem with Windows 7 or 8. It's actually a problem with applications that update environment variables such as PATH.
The PATH is stored in the Registry as an "Expandable string value" (REG_EXPAND_SZ), but a lot of applications write it back to the Registry as a "String Value" (REG_SZ). If your path contains anything like %SYSTEMROOT%, this will not be expanded into C:\Windows (or whatever yours is) if the path is stored in a REG_SZ.
The fix is simply to edit your path manually from the control panel. You need to make a change (eg add a ; to the end of the path) and then apply it. This will fix up your path in the Registry to be a REG_EXPAND_SZ.
(Go to the System Control Panel and select Advanced System Settings. Edit the Path Environment variable in the lower box, and that should fix it.
You can tell whether your path is broken in this way by opening a command prompt and typing PATH. Your path will be listed. If you can see anything enclosed in % % then your path is not being expanded.

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.

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

I also had a problem with xcopy (same error message) - with a very simple batch program that I use to backup files to a removable drive. Have been using that program for at least 5 years with never a problem. Then yesterday xcopy is unknown to Win7. The replacement of xcopy with %systemroot%\System32\xcopy at each instance solved the problem. Very strange.

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.

[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.

Related

Perforce CLI reconcile adds 'ghost' files to my working directory

Have a perplexing bug when I try to reconcile work through the CLI for perforce in that I get a large amount of files detected and added to the changelist whenever I run the command.
This happens regardless of where my current working directory is but the files always come from there, if my working directory is outside the project's root I get a 'Path {path} is not under client's root' error and they are not added, however if my working directory is under the project root they are detected and added as missing files.
I've tried numerous different combinations of the reconcile command, explicitly stating the port, user, client etc., setting up P4Config, using relative and absolute paths, changing the working directory - but I always get these ghost files.
Has anyone come across this before? Could this be a bug with P4 itself?
Edit: I finally fixed this by reinstalling P4V so I'm assuming this was some bug either my install of perforce or any local config files that would have been reset upon reinstall. For reference this is the page that finally fixed it https://community.perforce.com/s/article/15324
This is the result of the following bug:
https://www.perforce.com/perforce/doc.current/user/relnotes.txt
Bugs fixed in 2020.1 Patch 1 (2020.1/1991450)
...
#1964794 (Job #102470) *
'p4 reconcile'/'p4 status' might report about invalid filenames
of the form '//depot/0' or '//depot/100', etc. This is fixed.
Since this was fixed in a 2020.1 patch, it can be inferred that it only affects specific 2020.1 builds (i.e. those before the patch).
To fix it, make sure you're on a client version (p4 or P4V; this is not a server-side bug) whose changelist number is higher than 1964794. No special reinstallation procedure is needed; just download the latest binary/installer from Perforce's website.
Force a reinstall of P4V to fix this, details can be found here:
https://community.perforce.com/s/article/15324
Or if that page is taken down for any reason:
SOLUTION
Forcing a reinstall using the Windows msiexec installer utility with Windows msi installer file extracted from the p4vinst64.exe file can often successfully complete a full reinstall where running the P4V exe installer such as "p4vinst64.exe" fails
If not already downloaded, obtain the appropiate Windows installer for P4V (for example "p4vinst64.exe" for 64 bit Windows platforms). Currently these can be downloaded from https://www.perforce.com/downloads/helix-visual-client-p4v
Extract the msi from p4vinst64.exe; for example to extract it to "c:\p4v", open a Windows a cmd prompt and change directory to the location where p4vinst64.exe .is located and run the following command:
p4vinst64.exe /s /b"c:\p4v" /v"/qn"
Now from c:\p4v, run the following command to force a full reinstall:
msiexec /i "p4vinst64.msi" /qn REINSTALL=ALL REINSTALLMODE=vamus /L*v log.txt

Changed Starting Path with PowerShell Profile But Cannot Change it Back

While learning Anaconda I had a problem with "cd" not working in Anaconda PowerShell, so I did what is recommended here, manually created a profile and set the path to a specific folder. It worked.
But today somehow I found "cd" is working for me again, so I was going to delete that ps1 file. But the folder together with the file in that was no loner there, completely gone. Now I am stuck with my temporary path on every PowerShell start-up.
According to Microsoft documentation, $profile should return my profile variables, which it did:
C:\Users\myname\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
But first, this is not the file name I gave it; second, this path is also non-existent, both folder and file.
I tried notepad $profile, then Notepad told me "The system cannot find the path specified." But it is exactly the path the system told me.
Some answer I saw here says that is because my profile is non-existent, I need to create one first. That is not the case here. I definitely overwrote my starting path, but I cannot find the actual profile file to edit that back.
I also tried doing it the same way again but changing "YOUR_FILE_PATH" into "%Home" hoping to "overwrite" it back, yet somehow this time it did not work and the file did not disappear as it did the first time.
I am really confused on this.
If you want to reset PowerShell to the original settings when PowerShell was installed.
Uninstall PowerShell from the Add or Remove Programs.
Restart your computer.
Reinstall PowerShell.

Flutter Command - Powershell.exe not in PATH error message

I have flutter installed and everything works fairly alight but every time I run a flutter command I get the following message before the command actually runs.
Error: PowerShell executable not found.
Either pwsh.exe or PowerShell.exe must be in your PATH.
I added the Powershell.exe path to my PATH variable (both System & User) and also added C:\Windows\System32 as I read that on one of the Github/SO forums. Any idea how to get rid of this? I am following a Udemy course and have followed every instruction to the dot but the instructor does not get this message.
Go "Edit environment variables for your account" under "User variables" add to Path this line
C:\Windows\System32\WindowsPowerShell\v1.0
It solved my problem.
Add this to user Path variables and system path variables
C:\src\flutter\bin
Add these to Environment System Path Variables
C:\Program Files\Git\cmd
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32
My problem was the missing of 3rd from System path variables.
I have lost half a day to solve it and used all instructions on flutter site and and answers about powershell path. It didnt work until add C:\Windows\System32 to Path variable.
copy the path, for my case, it is "C:\Windows\System32\WindowsPowerShell\v1.0" and pastes it in environment variables as a path
In case you encountered this problem and none of the above solutions worked for you. In my case, I set all the environment variables - I am using Windows 10. I even reinstalled flutter; but the problems persisted.
It turns out my Anti Virus had quarantined the Powershell executable file. I had to open the anti virus quarantine chest, restored the Powershell executable and restarted my VS Code.
Problems solved, after three days of searching for solutions.

Overriding extensions directory in vscode

One can specify the extension dir by running from command line:
code --extensions-dir c:\path\to\ext
However, I would like to set this parameter even when running from the windows menu.
I tried to modify the argv.json file located in the .vscode folder (like for https://code.visualstudio.com/docs/getstarted/locales).
It didn't work.
Does anybody know how to fix this?
Bests
Try creating an environment variable called VSCODE_EXTENSIONS with the value of c:\path\to\ext
As a complement to DG's response
If the VSCODE_EXTENSIONS environment variable is created as a system variable, it seems to affect all users.
In my case, I performed the following steps:
close VSCode on all users (I usually have one session open as
administrator and another as non-administrator)
set the variable VSCODE_EXTENSIONS = c:\ProgramData\Code\extensions\
moved all extensions from the extensions folder of the administrator to c:\ProgramData\Code\extensions\
restart the computer
log in with both users and the extensions were available
It is convenient to mention since then the extensions installed by administrator are available to all users and are installed in the folder mentioned previously.

Doxygen failed to run html help compiler, hhc.exe error HHC5010 when running from folder that has a parent folder that starts with "."

I am using Conan package manager on Windows to create a package. The conan command to create the package copies files to a folder within %USERPROFILE%\.conan (or C:\Users\xxxxxxx\.conan). Then from this location it builds a Visual Studio project and ultimately calls doxygen.exe to create a .chm help file in a post-build command. The doxygen command fails with:
error : failed to run html help compiler on index.hhp
Further investigation reveals the hhc.exe command executed by doxygen is failing with:
C:\Users\xxxxxxx\.conan\data\Module\1.0.0\user\channel\build\524dc97e4a3dd1f774ea3897f9e4faf26c5457d2\Documentation>"C:/Program Files (x86)/HTML Help Workshop/hhc.exe" html\index.hhp
HHC5010: Error: Cannot open "C:\Users\xxxxxxx\data\Module\1.0.0\user\channel\build\524dc97e4a3dd1f774ea3897f9e4faf26c5457d2\Documentation\html\Module.chm". Compilation stopped.
Close inspection reveals that in the error message, the ".conan" folder is missing. Sure enough, I confirmed that hhc.exe fails when the index.hpp resides in a folder that has a parent folder that starts with a ".".
Attempts to resolve this:
changing the Doxyfile setting OUTPUT_DIRECTORY to "$(TMP)/DoxygenModule" resolves the error, but creates the .chm file in another location, which I do not prefer.
navigating to the 8DOT3 name of the ".conan" folder, which is "CONAN~1", to run the hhc.exe command, succeeds, but unfortunately I have no way of getting conan to use this 8DOT3 path for creating the package. E.g. C:\Users\xxxxxxx\CONAN~1\...
I can live with the using the %TMP% folder but would prefer generating the .chm in the current folder. Anyone have any ideas?
HTML Help Workshop v1.31 is installed on my machine at C:\Program Files (x86)\HTML Help Workshop, probably from a Visual Studio installation (not sure). I attempted using a version downloaded from Microsoft website (v1.30) as well, which made no difference.
Other info: Conan version 1.18.0, Doxygen version 1.8.14, Windows 10 Version 1809
Unfortunately not a solution, but this is a known limitation in the hhc.exe, see: https://social.msdn.microsoft.com/Forums/en-US/0681145c-223b-498c-b7bf-be83209cbf4e/issue-with-html-workshop-in-a-windows-container?forum=visualstudiogeneral
HTML Help 1.x command line compiler hhc.exe cannot compile CHM file to folder whose full path contains folder name starting with dot. If you have that problem, you probably specified output path with folder starting with dot, e.g. "d:\My files.NET\documentation". You can use dots in folder names but not at the beginning.
Edit 2019-11-15:
I've just pushed a proposed patch to github (pull request 7402, https://github.com/doxygen/doxygen/pull/7402).
This proposed patch changes inside doxygen from the current directory to the short named current directory, but just for the HTML Help compilation.
Edit 2019-11-16:
Code has been integrated in the master version on github.
This is not an answer either. Actually, you found the answer and workaround[s] yourself.
Use OUTPUT_DIRECTORY to specify a directory containing no folder names beginning with periods.
The error you described is a known issue of the MS HTML Help compiler. More general, the HTML Help compiler does not like some folder and file names. Try and stick with these characters _, a..z, A..Z, 0..9. Do not use these signs in particular ., -, # .
Please note that the proprietary CHM file format is about 20 years old (Windows 95, ...). HTML Help is in maintenance mode, which means no new features and bug fixes are expected for either the runtime or the compiler. All mainstream development on HH has stopped.
There is no way to avoid this error if a directory name above begins with a period. Not even if only the necessary files are written by Doxygen and compiling of the index.hhp is done by a third-party tool like FAR HTML using your path that contains .conan. This is because all applications are using the faulty HHA.dll.
The above applies of course to the entire workflow you have described. Maybe you can interrupt it.
Doxygen can be configured not to call the HTMLHelp compiler. Just uncheck the GENERATE_HTMLHELP option (DoxyWizard: Experts > Topics > HTML). You have all files generated by Doxygen in your preferred output directory - but of course without the CHM file. This can be imported later e.g. by HelpNDoc and compiled as a CHM file in another location.
If you can interrupt the workflow and can also make changes to Doxygen's settings, then a preference setting of OUTPUT_DIRECTORY to e.g. C:/CacheMenu/CONAN~1/DOXYGE~1 also works as expected (here used as test case).
No matter what you do, your workaround and copy and paste from another directory outside is a quick solution at this stage. Please note the EDIT in #albert's answer.