GQBSATO
Posts: 9
Joined: Fri May 08, 2015 2:56 am

Batch file error during installation

Dear Support,

I previously posted this topic (http://www.advancedinstaller.com/forums ... =2&t=30463) and decided to use a different approach instead (uninstall old version created from Visual Studio and install new version created from Advanced Installer) since I don't know the Product code of the existing product.

Now, I want to run a batch file (refer to the code below) that uninstall an existing application. It was working fine if I clicked it directly (usually it would take 9 seconds to complete).

//==================
@Echo off
Echo This is a batch file uninstallation program.
Echo Run as administrator WMIC will not work.
echo.

wmic /INTERACTIVE:OFF product where name="MyApplication" call uninstall
//==================

Then I followed the article in your site(http://www.advancedinstaller.com/user-g ... -file.html) and was able to add the batch file in the installer and build. Now I'm having a problem, it seems that it's not running(or has errors) and my old application still there even after the installation was completed.

Note: Both application resides in the same directory. Please refer to my Custom Actions screen (custom_action_barchfile.png) in the attached file.

Best Regards,
Glenn
Last edited by GQBSATO on Wed Jun 17, 2015 3:27 am, edited 2 times in total.
a.guelle
Posts: 97
Joined: Tue May 19, 2015 2:23 pm

Re: Batch file error during installation

Hey Glenn,

you may pipe the output of your batch to a text file. Just add

Code: Select all

> myLog.txt
to the arguments of our custom action. This way you can see if it was executed and you have the possibility of debugging with echo.
Not very handy but it's the way I am working.

Cheers,

Angelo
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Batch file error during installation

Hello Glenn,

I'm not sure why this happens. Can you please send us the .AIP (project file) and a verbose log of the installation to support at advancedinstaller dot com so we can investigate them?

Also, you can try the Angelo's suggestion to redirect the output of your BAT file to a text file and check the text file after the installation. Maybe this points you towards a useful hint.
ote: Both application resides in the same directory. Please refer to my Custom Actions screen (custom_action_barchfile.png) in the attached file.
I'm afraid I cannot find any attached PNG image on this thread. Did you forget to attach it? If so, please feel free to attach it bellow.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
GQBSATO
Posts: 9
Joined: Fri May 08, 2015 2:56 am

Re: Batch file error during installation

Hi Daniel, Angelo,

I attached the file but it was not successful even if I tried it again. Anyway, I uploaded it in my dropbox account (refer to the link below). I'll try what you suggested and will update you soon.

https://www.dropbox.com/s/2eotf17d3omj5 ... e.png?dl=0

Thanks and Best Regards,
Glenn
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Batch file error during installation

Hello Glenn,

Please keep in mind that regular files added in "Files and Folders" page are deployed during installation on target machine during the "Install Execution Stage -> Add Resources" action group on deferred stage. Therefore you should either add your "LaunchFile" custom action after "Install Execution Stage -> Add Resources" action group as deferred or add your BAT file as a temporary file in "Files and Folders" page and keep you custom action scheduled as immediate (before "Searches" action group).

As a side note, please keep in mind that during a silent installation only the "Install Execution Stage" actions are executed. Therefore, if you choose to add your BAT as a temporary file, then it is recommended to move the custom action after "Install Execution Stage -> Paths Resolution" action group.

If you have any questions or doubts just let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
GQBSATO
Posts: 9
Joined: Fri May 08, 2015 2:56 am

Re: Batch file error during installation

Hi Radu,

Thanks for your reply.

I followed your advice about using the temporary file, the batch file was launched automatically without any errors. Using Angelo's advice, I was able to get the logs from my Batch file. Unfortunately, the old program is still there. I know WMIC command would only work if its "run as administrator". In the "LaunchFile" custom actions, I already selected "Run as Administrator". Any idea what I missed in settings?

//=============
This is a batch file uninstallation program.
Run as administrator WMIC will not work.
Uninstalling...
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 1618;
};
//=============

Thanks and Best Regards,
Glenn
GQBSATO
Posts: 9
Joined: Fri May 08, 2015 2:56 am

Re: Batch file error during installation

Hi Dan,

I managed to make it work by putting the custom action(Launch file) after the "Paths Resolution" in the "Wizard dialog stage" instead of the "Install Execution Stage". The error 1618 from the msi seems to be related with some resources being already used in the current installation (just my guess).

Thanks for all the help.

Best Regards,
Glenn
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Batch file error during installation

Hello Glenn,

You're welcome. I'm glad you got this working.

Indeed, if the other product installation you try to uninstall within your main project is also MSI-based, then the uninstall action will fail if triggered within the "Install Execution Stage" of your main setup. This is because Windows Installer doesn't allow two (or more) installation/uninstall processes to run in the same time. This is a Windows Installer limitation. As you already saw the only way to uninstall the other product is by scheduling your uninstall custom action in the "Wizard Dialogs Stage".

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”