codemonk3y
Posts: 62
Joined: Thu Nov 01, 2012 3:51 pm

VBScript Inline Custom Action

I'm trying to run a vbscript with the Inline custom action instead of having to attach a temp vbscript. With our old application we have a process that's running and i need to call that exe with it's uninstall command, because we're no longer using it in our new version. In the ExecuteScriptCode custom action my script text is:

CreateObject("WScript.Shell").Run("""Session.Property("APPDIR")\my app\myupdater.exe"" /killmyupdater")

Seems to be an issue with trying to get the appdir, but not sure how else to get it.

The msi log gives me:

Action 11:25:27: ExecuteScriptCode.
Action start 11:25:27: ExecuteScriptCode.
Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action ExecuteScriptCode script error -2146827282, Microsoft VBScript compilation error: Expected ')' Line 1, Column 56
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: VBScript Inline Custom Action

Hello,

Please keep in mind that when is resolved APPDIR property value ends with an backslash character ("\"). So, can you remove the backslash character before "my app" folder and see if the behavior still persist?

Also, as another approach you can use a "Launch file or open URL" custom action like this:
  • Command: "[APPDIR]my app\myupdater.exe" /killmyupdater
Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
codemonk3y
Posts: 62
Joined: Thu Nov 01, 2012 3:51 pm

Re: VBScript Inline Custom Action

Thanks, that works. If the file is not there it fails. I'd like it to only run if the file is there. Can I do that in the same custom action?

Thanks,
Scott
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: VBScript Inline Custom Action

Hello Scott,

In order to achieve this you can add a file search (e.g. MY_SEARCH) on "Search" page. Then, you can use the search associated property (MY_SEARCH) in the "Condition" field of your custom action.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
codemonk3y
Posts: 62
Joined: Thu Nov 01, 2012 3:51 pm

Re: VBScript Inline Custom Action

That works if I know the full path of the file. I tried to us [APPDIR]my path\myexe.exe and it never finds it because [APPDIR] has not been set before the search runs.
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: VBScript Inline Custom Action

Hello,

Indeed, unfortunately you cannot use the APPDIR property as folder location path of your file search. However, in order to achieve what you want you can use a folder location like this:

Code: Select all

[ProgramFilesFolder][Manufacturer]\[ProductName]
for your file search.

Let us know if this helped.

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

Return to “Building Installers”