Problem with running batch file after installation - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

lakpappu
Posts: 9
Joined: Fri Feb 19, 2010 1:39 pm

Problem with running batch file after installation

Hi Team,

I have a requirement where my application has apache,Mysql binaries that get installed along with my application.After the install of version 1.0 I want to run a batch file which starts apache and mysql required for the application.

From then on when ever I send some patches(say 1.0.1,1.0.2 etc) to the clients machine I need to

1)Run the batch file to Stop the apache and mysql.
2)Run another batch file to start apache and mysql.


Below are the steps I followed to test the step2 above for my first installation(version 1.0):

1.Created a sample bat script(attached below) which would start the notepad.exe.I want to run this bat file after the installation is complete.

2.Created a install finalize custom action from Custom action->Show standard action->Before Finalization->Install Finalize->New Installed Custom Action.Attached are the exact steps I followed(install Finalize Custom Action.zip)

During the installation everything works normally and a notepad gets opened.But During the uninstall I get the error below and also a fatal error popup:
Uninstall1.gif
Uninstall1.gif (7.51 KiB) Viewed 6915 times

Please suggest me how to solve this problem.

Also during the patach upgrades I want to run a batch file that has to close the notepad.exe first and after patch installation it performs the steps above(open a notepad).

I could do this also by following similar steps as above Custom action->Show standard action->Before File Installation->Install initialize->New Installed Custom Action.It works fine during the patch installation but during uninstall it shows the same errors as above.Please suggest an approach for this one also.
Attachments
batch files.zip
(286 Bytes) Downloaded 323 times
install Finalize Custom Action.zip
(158.74 KiB) Downloaded 415 times
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Problem with running batch file after installation

Hello,

The bat file you are launching is no longer there when run during uninstall. It has already been uninstalled. That's why you are receiving the error. Try placing the bat that needs to run during uninstall right after InstallInitialize (it is important to be placed before RemoveFiles standard action)

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
lakpappu
Posts: 9
Joined: Fri Feb 19, 2010 1:39 pm

Re: Problem with running batch file after installation

Hi Gabriel,

I am not sure if you got my problem right.I have to run a batch file before installation(to stop the tomcat,Mysql) and after the completion of installation(to restart the tomcat,Mysql).

As of now I dont want to run anything during the uninstall process.But when I am uninstalling the bat files that I placed in install finalize standard action is running which shouln't be the case.How do I prevent this from running during uninstall.

Thanks,
Pavan Pappu.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Problem with running batch file after installation

Hello Pavan,

Sorry for the misunderstanding.
To prevent the custom action from running during a remove operation, you can condition your custom action by using the following condition:

Code: Select all

NOT REMOVE ="ALL"
This can be done by selecting the custom action and filling in the Condition field from the right pane.

Do let me know if this helped.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
lakpappu
Posts: 9
Joined: Fri Feb 19, 2010 1:39 pm

Re: Problem with running batch file with command line arguments

Thanks for the update Gabriel.

Instead of doing this I added a installed standard action to the install action and the problem got solved the (.bat file is executed only during the install process).

But I came across an other problem during the install process because of an error my bat file throws while installation.


I know this is not a problem with the windows installed but I need to have some workaround to resolve this issue.Could you please help me in arriving with a different approach to solve this problem.
.Below is the .bat file screenshot.

echo %CD%

set SERVER_HOME=%CD%-->Here actually I am trying to get the path of installation(eg: c:\Program Files....).But I am getting c:\windows\win32...


I tried to resolve the issue by passing this path as a command line argument([APPDIR]) while adding standard action in the install standard action as below:
arguments.gif
arguments.gif (10.08 KiB) Viewed 6890 times

But since the install directory is c:\Program<space>Files\.. the command line argument is split into many parts and when i say set SERVER_HOME=%1 I get only c:\Program.Due to which my rest of the program is not getting executed.Is there any other approach.


echo %SERVER_HOME%

set JAVA_HOME="%SERVER_HOME%\components\jre6"

SET JAVA=%JAVA_HOME%\bin\java

SET JAVAW=%JAVA_HOME%\bin\javaw

start /B %JAVAW% %JAVA_OPTS% -Dfile.encoding=UTF-8 -Xms512m -Xmx1024m -Dtest.dir="%SERVER_HOME%" -Dlog4j.configuration=file:./conf/log4j.xml -Duser.language=en -cp "%CLASS_PATH%" com.kc4l.app.startup.StartupService
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Problem with running batch file after installation

Hello,

You can first try placing [APPDIR] inside quotes: "[APPDIR]". If this fails to work, you can try using a "Launch File or Open URL" custom action and place there the entire command which looks something like:

Code: Select all

cmd -c "[&your.bat]" "[APPDIR"]
Where [&your.bat] is your bat file added using the "Edit" button to the right of the text edit. Do not forget to condition this custom action using the condition I mentioned in my earlier post.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”