.exe is not a valid Win32 application on Windows XP
Solution 1
From the Visual Studio Command Prompt, run this command:
Dumpbin.exe /headers c:\where\you\put\it\setup.exe
Where "setup.exe" is the setup EXE created by your installer creator. I'll post an example of the info you see that matters here:
OPTIONAL HEADER VALUES
10B magic # (PE32)
...
4.00 operating system version
0.00 image version
6.00 subsystem version // <=== here!!
0 Win32 version
...
The subsystem version number is important. VS2012 is the first version of Visual Studio that started setting this value to 6.00, the version number of Vista. Previous versions, as well as VS2012 when you target .NET 4.0 or earlier, will set this version number to 4.00
This is otherwise an important move ahead and part of phasing out support for XP. Windows version 6.00 and up, Vista, Win7 and Win8 pay attention to this number. They'll assume that your program is unaware of later Windows features and needs to have several appcompat shims turned on. The most notable one is appcompat in Aero, the desktop theme that displays windows with fat borders that are easy to click with a mouse. Windows will lie about those borders, telling you that your window is smaller than it actually is. A great source of confusion to programmers that try to make windows line up with each other.
The consequence of seeing 6.00 displayed is that your setup program cannot run on XP anymore. It is version 5.02.
So do make sure first that you do not target .NET version 4.5, it is not available for XP. Use 4.0 instead. If you still have trouble then contact the vendor's support and ask them how to control that number in the setup.exe file that the tool creates. A workaround is to run Editbin.exe with the /SUBSYSTEM option to change the number.
Solution 2
I am quite new to Visual Studio so I am not sure if the below option is added
recently but Visual Studio 2013 has a backward compatibility option to incorporate
Win_XP in target list. The below image helps :
And then when I run the dumpbin
command, I got the below results.
So now the application, under normal circumstances, can be run in Windows XP.
Hope this is helpful.
Rahul Shirphule
Develop Mobile application for both the leading platform iOS & Android.
Updated on October 03, 2020Comments
-
Rahul Shirphule over 3 years
I'm using Visual Studio 2012 Professional and creating an installer by using Advanced installer (3rd party).
When I run the installed .exe on Windows XP, I get the following message:
<appName>.exe is not a valid Win32 application.
The installed executable works fine on both Windows 7 and 8.
How can I get the program to work on Windows XP?
-
JDennis over 10 yearsUsing Windows Server 2012, I found editbin.exe to be unhelpful. In my solution, using IExpress.exe (system32 version), I package an Install.msi inside a setup.exe with frameworknet40. Although each dll is compiled with x86, including the Install.msi, IExpress sets the machine as x64 (results from FILE HEADER VALUES in dumpbin.exe). It was only when I used IExpress.exe on a Win XP 32 bit machine was I able to create a valid setup.exe.
-
Wayne Uroda almost 9 yearsThanks, this helped me (building a tiny C based exe). Maybe you could edit your answer to explain the setting in text, in case somebody cannot see the images.