How to interpret pre build error codes from Visual Studio 2010 - visual-studio-2010

I have been working with Visual Studio pre build events and I find the error codes rather unhelpful
for example, adding a pre-build event like this:
$(ProjectPath)\DoStuff.exe
This gives me an error: exited with code 267
Or adding like this:
$(ProjectDir)\DoStuff.exe
This gives me an error: exited with code 9009
After a bit of poking about it's possible to figure out what needs to be changed to get the command line to work, but it would probably be far simpler if I could look up the error code and see what it meant.
I have tried google with some of these error codes but some are really hard to find any information about - for example 267 seems rather elusive.
Is there a list somewhere that defines all these error codes?
:)

Avoid shooting the messenger. Talk to the owner of DoStuff.exe and ask what these process exit codes mean.
If you have reason to believe that DoStuff is buggy and doesn't set the exit code properly then you can work around it by resetting the %errorlevel% value. Make it look like this:
dostuff.exe
cmd /c ""
The error codes you see could be Windows error codes as declared in the SDK's WinError.h file. Error 267 is ERROR_DIRECTORY, "The directory name is invalid". Error 9009 is DNS_ERROR_RCODE_NOTAUTH, "DNS server not authoritative for zone".

Related

VS2019 Pre and Post build events always fails with code 1

I have a solution with just echo Hello post-build event and it always fails with the message The command "echo Hello!" exited with code 1.
Has someone an idea what could go wrong?
More info:
we have a team with about 15 developers. It always fails just for 3 of them
we have all Windows 10 and VS2019
we have tried different scripts and ended up with the echo Hello
we have tried with the prod solution and with an empty one as well
Full error message:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\
Microsoft.Common.CurrentVersion.targets(1328,5):
error MSB3073: The command "echo Hello!" exited with code 1.
Edit
Just have compared the Microsoft.Common.targets file from a developer with working events to one with non-working events. They have the same content.
I don't have Visual Studio in front of me to test this, but the problem feels like ERRORLEVEL may sometimes (randomly?) be non-zero on entry to the post-build script.
The problem is that ECHO does not affect ERRORLEVEL:
dir FileThatDoesNotExist Gives "File not found".
echo %ERRORLEVEL% Prints "1" ... an error.
echo Hello Prints "Hello".
echo %ERRORLEVEL% Still prints "1".
Therefore, if error-level happens to be non-zero, it will not be reset by the ECHO command. (Neither, as far as I can see, does REM affect it). There may be other ways of doing so, but DIR . > nul seems to work for me in resetting ERRORLEVEL to zero (it should always be possible to run DIR on the current directory!). The redirect should stop the output appearing in the build-log.
Obviously, if there was an earlier command in the post-build script that had failed, you probably don't want to ignore it. However, the pattern you're seeing (some users fail, some work) suggests that for some reason, Visual Studio is sometimes launching the post-build script with a non-zero error-level: with an empty script, or only ECHO commands, this will end up as the "result" of the post-build stage and the problem you're seeing.
Adding DIR . > nul to the TOP of the script should ensure that the exit-code is reset (and will allow real failures later in the script to be detected).
So the problem was the username. We had some freelancers in our company and they got a username starting with some special character. I can't remember which one, but I guess underscore. So when the admin sorts users by their user name they are on the top.
Changing the username has solved the problem in all our cases -_-

Interpreting really strange error message

I'm messing around with some very complex build definitions in VS/TFS 2013 and the build is failing with the following error message:
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (1131): The command "cd C:\Builds\34\GEARView\Copy of GV-All\Sources\GEARView\RecordViewer\
attrib -r "C:\Builds\34\GEARView\Copy of GV-All\Sources\GEARView\RecordViewer*" /S /D
C:\Builds\34\GEARView\Copy of GV-All\Sources\GEARView\RecordViewer\Build.bat" exited with code 9009.
So what I don't get is what is failing? There's a "cd" at the beginning of the message, so is that failing or is it the "attrib" in the middle of the message or is it actually calling Build.bat and that's failing?
And while I'm here I might as well ask another question, which is what on earth could be calling Build.bat? I searched all files in source control and couldn't find the string "build.bat".
I took the spaces out of the name of the build definition and the problem went away ;-).

The filename or extension is too long

I try to compile project using PowerShell command.
Problem is that there is a lot of arguments (75000 characters)
When I try to run compilation I got error:
This command cannot be run due to the error: The filename or extension is too long.
I have also changed value in registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled but it didn’t helped.
I am using Windows 10 Pro.
Do you know where can be problem?
Just in case this grabs anyone else. I received this error but the real problem was my StartInfo.Arguments value was too big. It had nothing to do with the filename I was specifying.

While calling exe file from vb6, We are getting error exe stopped working

I called exe file from Vb6.
Shell "D:\Sample.exe RpNo, PrtVw, glngbr".
We are getting error exe stopped working
I meant to post this as a comment but don't have enough rep to do that.
First of all Shell "D:\Sample.exe RpNo, PrtVw, glngbr" I think the only part of the name of the program you are trying to open is only "D:\Sample.exe" and the rest without the "" quotes so you can try Shell "D:\Sample.exe", RpNo, PrtVw, glngbr
Secondly try opening the program you want to open with the shell statement and see if you get the same error because getting that error should have nothing to do with the program you used to open it the error would be coming from the program "Sample.exe" also what is RpNo, PrtVw, glngbr I've never seen that before, and tried that myself and it didn't work at all, try these out and I hope this helps.

VBScript to move files gets error "Expected statement"

I am writing a script to move files between directories. I copied and edited this script from another post:
MOVE C:\Users\evan\Downloads\*.mp3 C:\Users\evan\Music
and I run it from the CLI using
cscript test.vbs
I would expect it to work, but I get this message:
C:\Users\evan\test.vbs<1,8> Microsoft VBScript compiliation error: Expaected statement
Can someone please explain what this error message means or point out my mistake that causes the error message? Sorry for being such a noob.
That looks like a batch file, but you are trying to invoke it as a VBScript. Rename your file to .bat and invoke it directly.

Resources