Posts
24
Comments
14
Trackbacks
0
February 2009 Entries
Launching an Arbitrary VBScript From Within MSI Package

Recently I was given a task of building an MSI package that among other things needed to include a VBScript in it. The VBScript would run at the end of the installation process.
Because I used to build install packages on and off in the past that also included various VBScripts I did not think twice, simply rolled up my sleeves and started a new Setup project in Visual Studio.
While doing an initial build I noticed that it is not so easy to incorporate some advanced features into the project as chaining other MSI packages, starting and stopping services, creating environmental variables, etc.
Finally, to my disappointment, I could not get the VBScript executed at the end of my installation package!
An error about VBScript not being able to run popped up.
What a surprise, I was tempted to blame the Visual Studio for that failure and simply decided to switch to another install tool to try.
Although this time I wanted the luxury of having a tool easy to work with that would have the features I needed and also flexible enough. After some digging into the Internet I was able to find an excellent alternative from wItem Installer2Go.
Alas, after building an MSI package this time five times as fast with it I received the same result. The script would not run!
I started to suspect something is wrong with my script and did the installation with logging turned on via command line.
Well, the error was there it was can’t create object: WScript.Shell Hmm, I puzzled for a moment and scratched my head, I was sure I had successfully deployed several MSIs with a VBScript in them before.
After some research the issue became evident: You cannot use the WScript object in scripts that are called by MSIExec.
An excellent article is this at SpinnerSoftware or a discussion thread on the Microsoft's Communities website.
This does make sense to me, one cannot have a handle to WSH from MSI.
Well, the only positive outcome is I now have a very nice Installer at hand I will be using.

Update: Justed used another approach and it works. You can instead create an executable off the same, slightly modified VBScript (only a Sub Main procedure needs to be added), the tool I used is a freeware ScriptPad.

posted @ Sunday, February 22, 2009 7:11 PM | Feedback (0)
Forcing MSI Installation Into a Specific Directory
Yesterday I was doing an upgrade to a product and I needed to install it into the path where the old version used to be. I only needed to figure out what install option I need.
 
I knew MS Installer supports a vast number of command line options, I hoped that it will be easy to find the correct one, but looking into the MSDN’s help did not help finding the necessary Public Property right away, it simply was not immediately obvious.
So I tried one property then another and finally in frustration decided to turn on the logging to see what the MSI package is doing when I change the default destination path.
Examining the produced file immediately yielded results – bingo, the right property was very evident, buried in the middle of my install log - TARGETDIR. The rest was easy:
I created a custom command line install directive
msiexec /passive TARGETDIR="C:\MyTagretDirectory" /i MyProject.msi
And was able to get the desired path pre-populated!
 Install Path
In my case I did not want the user to interact with the installer and therefore added the /passive option which reduces the MS Installer GUI to merely a progress bar.
posted @ Tuesday, February 17, 2009 1:31 PM | Feedback (2)
News
Did you know you can create your own search engine with Google?