Setup.exe Bootstrap Sample and APPVER

Avatar

Heath

On an internal alias – which inspires many of my blog entries – someone
wasn’t able to run the sample bootstrap executable setup.exe, found in
the Samples/SysMgmt/Msi/Setup.exe folder in your
Platform SDK installation
root. The error was "setup.exe is not a valid Win32 application" when run on
Windows 2000 but the sample worked fine on Windows XP. Right away it would seem
that something in the

PE headers
of the sample something is wrong. Take a look at part of the
dumpbin.exe
output:

Because the subsystem version is 5.01 the executable will run on a minimum
operating system of Windows XP. So how did this happen?

If you build the setup.exe sample using the build environment consoles
also installed with the Platform SDK, the environment variable APPVER is set
according to which OS you pick in the current options. If you started the
shortcut "Set Windows XP 32-bit Build Environment (Retail)" then APPVER is
defined as 5.01. This variable is used many places in the win32.mak file
included by Makefile in the setup.exe sample directory.
Particularilily this is why the subsystem was set to 5.01:

# Windows 98 needs subsystem
version set to 4.10 for version 5.0 features.
!IF ("$(APPVER)" == "5.0") && (("$(TARGETOS)" == "BOTH") || ("$(TARGETOS)" ==
"WIN95"))
EXEVER = 4.10
!ELSE
EXEVER = $(APPVER)
!ENDIF

# ———————————————

# for Windows applications
conlflags = $(lflags) -subsystem:console,$(EXEVER)
guilflags = $(lflags) -subsystem:windows,$(EXEVER)

So when building setup.exe make sure you set APPVER according to your
platform requirements. You can either start the appropriate build environment
console or after starting the console set APPVER to 4.0, 5.0, 5.01,
or 5.02. Future versions of the Platform SDK for future versions of Windows will
likely include support for additional values.

Avatar
Heath Stewart

Senior Software Engineer

Follow Heath   

No Comments.