Basic .bat file Custom Action won't work - 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!

kdougan
Posts: 3
Joined: Thu Jun 26, 2008 10:57 pm

Basic .bat file Custom Action won't work

I have a batch file test.bat in my Application Folder and the .bat file contains one line:
echo Hello > C:\out.txt
In the InstallExecuteSequence | Install folder I have created a Custom Action using the New Custom Action Wizard. I have select the 6th item Open Another Kind of File, and the source is A File Installed by this Package. I choose the source file test.bat from the file list dialog, and the source file shows as APPDIR\test.bat and in the Standard Action dialog I select Install. After I select Finish button the Properties dialog show the Source Path as C:\ProgramFiles\Caphyon\Advanced Installer 6.4\custact\viewer.exe, Source Type as *.exe, and the Command Line as [#test.bat]. I also have Synchronous execution, ignore return code, Deferred, Execute Always, and Execution Condition NOT installed.

When I run the .msi created by AdvancedIinstaller I get an error message "This file does not have a program associated with it for performing this action."

What am I missing?
Thanks
Ken
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Basic .bat file Custom Action won't work

Hi Ken,

Can you launch the BAT file directly (outside Advanced Installer) on the machine which shows this behavior? I tested the scenario you explained and the BAT runs correctly. Perhaps on your machine the .BAT extension has an incorrect file association.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kdougan
Posts: 3
Joined: Thu Jun 26, 2008 10:57 pm

Re: Basic .bat file Custom Action won't work

The .bat file works correctly if I double-click on it IE, and if I right-click it in AI's File and Folders | Application Folder and select Open, it also creates the c:\out.txt file. Further, if I do the following:

C:\Program Files\Caphyon\Advanced Installer 6.4\custact>viewer "C:\projects\trunk\test.bat"

this also creates the out.txt file.

It doesn't seem to work when I run the .msi file.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Basic .bat file Custom Action won't work

Hi,

I'm not sure why the custom action doesn't work. Can you please send us the AIP which shows this problem to support at advancedinstaller dot com so we can investigate it?

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kdougan
Posts: 3
Joined: Thu Jun 26, 2008 10:57 pm

Re: Basic .bat file Custom Action won't work

I recently upgraded from 6.1 to 6.4, so I remove AI and reinstalled it fresh from a new download of 6.4 Enterprise. So I know that my AI is a good clean state.

Just out of curiousity I tried running a .vbs as a custom action and that failed too. This is based on an older forum issue where a install properties file is searched for a tag that is replaced with the APPDIR location in the properties file:

Function main()

fileToChange = Session.property("APPDIR") + "install.prop"
realFilePath = Session.property("APPDIR")
strToFind = "C:\install_loc_tag"

ReplaceInFile fileToChange, strToFind, realFilePath
End function

Function ReplaceInFile(strFileToUse, strOldText, strNewText)
Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileToUse, ForReading)

strText = ""
strFile = ""

strText = objFile.ReadAll
objFile.Close
strFile = Replace(strText, strOldText, strNewText)

Set objFile = objFSO.OpenTextFile(strFileToUse, ForWriting)
objFile.WriteLine strFile
objFile.Close
End Function
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Re: Basic .bat file Custom Action won't work

Hi Ken,

1. Regarding the BAT file issue, make sure that you enclose the file reference within quotes, as the full path may contain spaces. That is, use "[#test.bat]", not just [#test.bat] in the "Command Line" field.

2. Regarding the VBScript Custom Action issue, note that Deferred Custom Actions do not have access to session Properties (such as APPDIR). You should set the "Action Data" field to [APPDIR] and in your VBScript Custom Action retrieve the CustomActionData Property instead of APPDIR:

Code: Select all

Function main()
  fileToChange = Session.property("CustomActionData") + "install.prop"
  realFilePath = Session.property("CustomActionData")
  strToFind = "C:\install_loc_tag"

  ReplaceInFile fileToChange, strToFind, realFilePath
End function
Also note that the Custom Action should be set as "Deferred with no impersonation" in order to work correctly in Vista.

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”