Add to My Yahoo! | Google Reader or Homepage | Add to Windows Live | Add to Windows Live Alerts

Wictor Wilén

SharePoint Server MVP / Author / MCT / MCTS / MCP / MSc writing about SharePoint and other interesting Microsoft technologies

WIX - CustomActions using VBScript

Posted at 2006-04-12 04:00 by Wictor Wilén in WiX , Scripting with 7 comments.
Here are some small tips when using VBScript CustomActions using WIX.

Creating a script CustomAction
First of all you have to create a CustomAction in your WXS file:
<CustomAction Id="Id_Of_ScriptAction" BinaryKey="Id_of_binary" VBScriptCall="Script_Name" />
Id_Of_ScriptAction is a unique Id of your CustomAction
ID_of_binary is the unique Id of the binary that contains the vbs file.
Script_Name is the name of the Sub or Function in your vbs file.

Creating the VBS file
Create a .VBS file with a function or sub that should be executed.
Sub DoThis
   MsgBox "Hello there..."
End Sub


Add a Binary to the WXS file
After creating the script you have to include it into your WXS file. This is done by creating a Binary element like this:
<Binary Id="Id_of_binary" src="Local_Path" />
Id_of_binary is a unique id
Local_Path is a local path (relative to the wxs file)

Add the action to the install sequence
After doing all this you have to tell the installer when and where to execute the custom action, this is done by adding the action to the InstallExecuteSequence element
<InstallExecuteSequence>
...
<Custom Action="Id_Of_ScriptAction" [After|Before|Sequence]="..." >Condition</Custom>
...
</InstallExecuteSequence>

Id_Of_ScriptAction is your custom action.
For more information on the Custom element and the After/Before/Sequence attributes, check out the WIX help file and/or this tutorial.
Note: The Execute attribute of the Custom element should be Deferred to execute during the install sequence or Immediate to execute it while the install script is executed, see MSDN for more information on this.

Comments and trackbacks

#  Interesting Finds by Trackback
Screenshot from websnpr
#  re: WIX - CustomActions using VBScript by anonymous
Screenshot from websnpr As an installshield developer, I find wix fascinating. As an aside to this article, the company I work for has recieved numerous tech support calls because vb script install custom actions set off virus scanners or fail without a warning when the user doesn't have sufficient permissions. We've migrated our sizable custom action code over to dlls written in c++.
#  re: WIX - CustomActions using VBScript by Wictor
Screenshot from websnpr Of course, making the custom actions in c++ dll is by far the best method to do it. But I think using script actions like this is very convenient when making installers quickly or when you have control of the target machine.
#  WIX - accessing properties in script CustomActions by Trackback
Screenshot from websnpr My last post showed how to use VBScript functions as CustomActions. More than often you need to access...
#  how to pass Parameters to the vbs by anonymous
Screenshot from websnpr Can you let us know how to call a vbs method by passing parameters.
#  How to take screenshots using VB Script? by jack
Can you please help me in taking screenshots using VB Script?
#  education by Alex
Screenshot from websnpr I am studying S/W Engg. and this is my last year. I am planning to do freelancer project. I need detail about freelancer project that is how and where do i get project and also the money for that project. I am specialist in web based projects and website developments, so i need web based projects
Make a comment on this post:
Subject:  

Your name:  
Your Url:  
Note: submissions may have to be approved before being visible, so don't submit your comment multiple times.
Real Time Web Analytics