markphip
Posts: 20
Joined: Fri Apr 16, 2010 9:03 pm

Batch files run from 64-bit installer use 32-bit cmd.exe

I have run into problems when making an installer targeted only for 64-bit systems. I have some custom actions at end of install that runs a batch file. When the batch file runs, it is being run as a 32-bit process so the batch file cannot invoke 64-bit apps because of the Wow64 redirection. In my case, I am trying to run the 64-bit java.exe that I installed as a pre-requisite.

On Vista and later, I can get around this by running it via:

%WINDIR%\sysnative\java

But this does not work on XP or 2003 as they do not support the sysnative trick without a special hotfix being installed. In fact, I do not know how to launch a 64-bit system process from the batch file on those systems. It seems like the better answer would be if the installer was running the batch files as 64-bit processes as it ought to. Then I would not have to deal with this in my scripts.

I am using 7.6.1 and this is an Enterprise project type.

Mark
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

Hello Mark,

Please make sure the following are true:
- your package is marked as 64bit from the Install Parameters page
- your custom action is marked as 64bit if applicable.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
markphip
Posts: 20
Joined: Fri Apr 16, 2010 9:03 pm

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

GabrielBarbu wrote: Please make sure the following are true:
- your package is marked as 64bit from the Install Parameters page
- your custom action is marked as 64bit if applicable.
Yes it is a 64-bit package.

The action has the 64-bit option grayed out. I believe this only controls whether or not it runs though -- which it does.

When you run a batch file from a custom action, it uses viewer.exe. I believe the problem is that this is a 32-bit application and launches a 32-bit cmd.exe.
markphip
Posts: 20
Joined: Fri Apr 16, 2010 9:03 pm

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

markphip wrote: When you run a batch file from a custom action, it uses viewer.exe. I believe the problem is that this is a 32-bit application and launches a 32-bit cmd.exe.
I should add that I am running AdvancedInstaller on a 32-bit Windows machine. Nothing in the documentation states it needs to be run from a 64-bit machine to create a 64-bit package, so I am assuming that is not a factor.

Mark
Bogdan
Posts: 2791
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

Hi Mark,

This is correct, it doesn't matter on which OS (32 or 64 bits) you are running Advanced Installer to create a 64 bit package, the package should be correctly
created on all machines.

If the package is a 64 bit one then the custom action should be launched as a 64 bit process and not get redirected.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
markphip
Posts: 20
Joined: Fri Apr 16, 2010 9:03 pm

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

Bogdan wrote:Hi Mark,

This is correct, it doesn't matter on which OS (32 or 64 bits) you are running Advanced Installer to create a 64 bit package, the package should be correctly
created on all machines.

If the package is a 64 bit one then the custom action should be launched as a 64 bit process and not get redirected.
That does not seem to be the case for launching batch files. As soon as I put in code to detect the runtime and that it was running as 32-bit mode it worked. The problem I now face, is that those workarounds do not work on XP and 2003 in 64-bit mode. The "sysnative" feature was not added until Vista.
Bogdan
Posts: 2791
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

Hi,
The problem I now face, is that those workarounds do not work on XP and 2003 in 64-bit mode. The "sysnative" feature was not added until Vista.
Indeed the problem is caused because the fact that "viewer.exe" from our application is a 32 bits file. The only solution you have is to create new custom action (exe or DLL) of 64 bits
that will launch your batch file.

This way the files will always run as 64 bits ones, without being redirected.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
markphip
Posts: 20
Joined: Fri Apr 16, 2010 9:03 pm

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

Bogdan wrote: Indeed the problem is caused because the fact that "viewer.exe" from our application is a 32 bits file. The only solution you have is to create new custom action (exe or DLL) of 64 bits
that will launch your batch file.

This way the files will always run as 64 bits ones, without being redirected.
Is there a reason I cannot use cmd.exe /c to run a script? I have not understood why viewer.exe is needed to run a batch file.

Are you going to file an enhancement to include a 64-bit version of viewer.exe?
Bogdan
Posts: 2791
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

Hi,
Is there a reason I cannot use cmd.exe /c to run a script?
Because this would suppose that you have added "cmd.exe" in your installation package, which you are not allowed to do since this is created by Microsoft,
not by you. This is why I suggested you create your own EXE or DLL of 64 bits that will run the batch file.
Are you going to file an enhancement to include a 64-bit version of viewer.exe?
I've already added this improvement on our TODO list, a future version of Advanced Installer will include it.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
markphip
Posts: 20
Joined: Fri Apr 16, 2010 9:03 pm

Re: Batch files run from 64-bit installer use 32-bit cmd.exe

I solved the problem by passing JAVA_HOME property into my script so that it does not need to access the java in System and is therefore not subject to the redirection.

Before doing this, I tried to use VBScript to run the batch file. I wrote a script that worked fine when I tested it, but whenever the installer would get to that phase it gave an error that implied it could not be found and the installer rolled back. I eventually gave up and tried this other technique which worked.

Thanks

Mark

Return to “Common Problems”