VB6 - After compiled getting compatibility issue on Windows 7 64bit [duplicate] - vb6

I'm using
cd C:\Program Files (x86)\Microsoft Visual Studio\VB98
vb6.exe /make Project1 /out %1
To basically compile my application, and I'm getting a compatibility issue (Saying doesn't work on my type of windows).
When compiling with the VB6 IDE (Make .exe) that works perfectly on my machine but this isn't, does anybody know how to fix this? Thanks
Error I receive when trying to open executable: "This version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 32-bit or a x64 64-bit version of the program, the contact the software publisher".
& It's a standard EXE application also.
I've tried running it as a administrator, trouble shooting / changing the compatibility to windows XP service pack 2 & 3, still didn't work.
Work prefer a good fix to this, like if there's anything I can do via console as a option or something or some option or anything.
Cheers! Please help ASAP

From the discussion in the comments, I believe the answer here is as follows (as identified by GSerg):
The problem is your use of the /make switch on the command line. The documentation says this about /out:
Outputs errors to a file when used with the /make or /makedll switch.
So, if you used vb6.exe /make Project1 /out Project1.exe, then Project1.exe would actually be a text file containing the error output from the compiler and thus would not be an actual executable, even though it had an .exe extension.
You actually don't specify the output binary when you use /make. The help output from running VB6.exe /? is a little more explicit:
Tells Visual Basic to compile projectname and make an executable file
from it, using the existing settings stored in the project file.
VB remembers the last filename and directory you used for compiling your project in the IDE, and it stores that in the .vbp file:
ExeName32="Project1.exe"
Path32="..\output"

I use a batch file to handle this issue. It sets the path to include both the 32-bit and 64-bit versions of the Program Files directories. Then just reference 'vb6.exe' and the correct one will be pulled from your path.
set PATH=c:"\Program Files (x86)\Microsoft Visual Studio\VC98\bin"
set PATH=%PATH%;c:"\Program Files (x86)\Microsoft Visual Studio\VB98"
set PATH=%PATH%;c:"\Program Files\Microsoft Visual Studio\VC98\bin"
set PATH=%PATH%;c:"\Program Files\Microsoft Visual Studio\VB98"
vb6 /m foobar.vpb

Related

PostBuild in Visual Studio 2008 not working under Windows 7 or Windows 8.1

I defined a post-build-event in Visual Studio 2008:
%ProgramFiles%\TortoiseHG\xy.exe
When compiling under Windows 7 or Windows 8.1 (x64) I got the following error-message:
Error 1 The command "%ProgramFiles%\TortoiseHG\xy.exe" exited with code 9009. MyProjektName
The program is here:
C:\Program Files\TortoiseHg
In Windows XP (x86) it is working perfectly - also did I try to set quotation marks but it didn't help. Any ideas what could be wrong? Is it a problem due to the fact that there are two program-paths (one for x86 and one for x64)? But even when I copy the xy.exe to C:\Program Files (x86)\TortoiseHg\, I do get the same error.
Help is appreciated! Thank you.
under Windows 7 or Windows 8.1 (x64)
That's certainly one of the basic problems, Visual Studio is a 32-bit process. The file redirector will act up and redirect any access from c:\program files to c:\program files (x86). To die there, you don't have TortoiseHG installed there.
But not your only problem, the redirection will produce error code 3, not 9009. So you did not get this far yet, 9009 is a general failure code produced when the program you start exits with an error code. Missing double quotes is enough to trigger it, also the program itself failing for whatever reason. Pretty important to look in the Output window for any error message.
Short from an error message we don't know about, you'd get closer with:
%windir%\sysnative\cmd.exe /c "%programw6432%\TortoiseHG\xy.exe"
Which starts the 64-bit command processor, thus ensuring that the file system redirector stays out of the way. The /c option asks it to execute the command that follows and then exit. The %programw6432% environment variable ensures you'll pass c:\program files and not the 32-bit path. Double-quotes around it to ensure that the spaces in the path don't cause misery.
Try $(ProgramFiles) instead %ProgramFiles%. I tried in VS2010 and it works. I suppose in VS2008 too. I normally use quotation, but I don't know if it is necessary.

VB6 compiling via console (vb.exe) compatibility issue on 64bit (works on 32bit?)

I'm using
cd C:\Program Files (x86)\Microsoft Visual Studio\VB98
vb6.exe /make Project1 /out %1
To basically compile my application, and I'm getting a compatibility issue (Saying doesn't work on my type of windows).
When compiling with the VB6 IDE (Make .exe) that works perfectly on my machine but this isn't, does anybody know how to fix this? Thanks
Error I receive when trying to open executable: "This version of this file is not compatible with the version of Windows you're running. Check your computer's system information to see whether you need a x86 32-bit or a x64 64-bit version of the program, the contact the software publisher".
& It's a standard EXE application also.
I've tried running it as a administrator, trouble shooting / changing the compatibility to windows XP service pack 2 & 3, still didn't work.
Work prefer a good fix to this, like if there's anything I can do via console as a option or something or some option or anything.
Cheers! Please help ASAP
From the discussion in the comments, I believe the answer here is as follows (as identified by GSerg):
The problem is your use of the /make switch on the command line. The documentation says this about /out:
Outputs errors to a file when used with the /make or /makedll switch.
So, if you used vb6.exe /make Project1 /out Project1.exe, then Project1.exe would actually be a text file containing the error output from the compiler and thus would not be an actual executable, even though it had an .exe extension.
You actually don't specify the output binary when you use /make. The help output from running VB6.exe /? is a little more explicit:
Tells Visual Basic to compile projectname and make an executable file
from it, using the existing settings stored in the project file.
VB remembers the last filename and directory you used for compiling your project in the IDE, and it stores that in the .vbp file:
ExeName32="Project1.exe"
Path32="..\output"
I use a batch file to handle this issue. It sets the path to include both the 32-bit and 64-bit versions of the Program Files directories. Then just reference 'vb6.exe' and the correct one will be pulled from your path.
set PATH=c:"\Program Files (x86)\Microsoft Visual Studio\VC98\bin"
set PATH=%PATH%;c:"\Program Files (x86)\Microsoft Visual Studio\VB98"
set PATH=%PATH%;c:"\Program Files\Microsoft Visual Studio\VC98\bin"
set PATH=%PATH%;c:"\Program Files\Microsoft Visual Studio\VB98"
vb6 /m foobar.vpb

How to create a shortcut for F# compiler (Fsc.exe)?

I have a stupid question to ask. I have just started learning F#, and I am trying to compile some basics examples (such as HelloWorld.fs).
I created a simple F# file whose path is: C:\FSharp\HelloWorld.fs.
In order to compile it, I used the full path of the F# compiler as follows:
C:\FSharp>"C:\Program Files\Microsoft F#\v4.0\fsc.exe" HelloWorld.fs
It worked perfectly.
However, I do not want to keep writing the full path of the complier: C:\Program Files\Microsoft F#\v4.0\fsc.exe. I tried to add it to Windows path,but I keep getting the error fsc is not recognized as internal or external command.
How can I create a shortcut word for F# compiler so that I don't have to use the full path everytime I need to compile a program?
For those arriving here in 2019 having received F# as a component of Visual Studio 2017. The location of the F# compiler is as follows:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsc.exe
Take careful note of the Version Type (Community in this case) and adjust yours accordingly.
You don't really need to create a shortcut for this, you just need to add the folder containing fsc.exe to your PATH variable.
When you open the command prompt, run this:
set PATH=%PATH%;"C:\Program Files\Microsoft F#\v4.0\"
or, if you're using a 64-bit version of Windows:
set PATH=%PATH%;"C:\Program Files (x86)\Microsoft F#\v4.0\"
The most recent version of fsc.exe can be found in these locations :
"C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0" // as of Aug 2014
"C:\Program Files (x86)\Microsoft SDKs\F#\3.0\Framework\v4.0" // 2013
I tried setting it to my path, but unfortunately it did not work. Tried logging off/restarting etc. I believe it is because of security measures in place on my work computer.
For other people having similar issues, I found that setting the alias not only worked but was more preferable over other methods.
set-alias fsi "C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsi.exe"
set-alias fsc "C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe"
Now the commands don't have the annoying .exe file extension.
Helpful in getting setup was this article on creating persistent aliasing for powershell.
http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-powershell-aliases/
I can confirm that adding the directory to your PATH variable should do the trick (works on my machine!) Note that you may need to restart any opened command line (or, just to make sure, the system) until the change is taken into account if you change the PATH variable in system properties.
You could also create a bat file with something like:
echo off
"C:\Program Files (x86)\Microsoft F#\v4.0\fsc.exe" %*
And then make sure the bat file is somewhere in your PATH. But the bat file can have a different name (say fsharpc.bat), in case there is some name clash between the standard name fsc and something else on your system...

Running vcvars32.bat before compiling in Code::Blocks?

I've installed Visual Studio C++ Express 2012 and want to use it's compiler with Code::Blocks. Starting cl.exe does not work (missing mspdb100.dll) until I run vcvars32.bat, but that does only hold on for the current session in the Command-line. The same applies to compiling with Code::Blocks.
How can I make it run the vcvars32.bat before compiling?
Workaround
That workaround is actually not what I was looking for, but it works, and that is important. Instead of letting Code::Blocks running cl.exe directly, I've set-up a simple batch-script that runs vcvars32.bat before running the actual compiler.
REM File: cl.bat
call vcvars32.bat
call cl.exe %1 %*
In the project properties, you have a section Build events. You can add vcvars32.bat to the pre-build event.
To run the .bat before compiling in Code Blocks(16.01), go to the project build options and its under the "pre/post build steps" tab. This tab only appears in the project settings, not the compiler settings.
However, adding "vcvars32.bat" (or "vcvars64.bat") to the pre build steps didn't fix the error for me.
I found the directory where the library is and added it to the linker search directories. This gave errors about further missing libraries. I added the following paths to my linker settings. These will almost certainly be different for you. I'm installed MSVS 2017 community edition. For some reason known only to Microsoft, the necessary libraries are installed on two different drives.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x64
D:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64
D:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64
Note that the .bat script is no longer necessary if you add these paths by hand.

nmake, visualstudio, and .mak files

I was given a C++ project that was compiled using MS Visual Studio .net 2003 C++ compiler, and a .mak file that was used to compile it. I am able to build it from the command line using nmake project.mak, but the compiler complains that afxres.h was not found. I did a little searching around and the afxres.h is in the Visual Studio directory in an includes file. Where am I supposed to specify to nmake where to look for this header file?
There should be an icon in your Start menu under Programs that opens a cmd.exe instance with all the correct MSVS environment variables set up for command line building.
Another option is running the appropriate vars batch file from a regular command prompt. The name and location varies from version to version. For VS2003, I believe it's
C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat

Resources