Dwarfsoft [GPA]

MSI Installer Limitations

by on Aug.28, 2008, under Novell, Scripting, Study, Work

Print This Post Print This Post

I have spent the last few days creating a few MSI packages and fixing some pre-existing MSI packages. One issue that I found with working on an MSI that installs files to a Hidden partition is that InstallShield has very little in the way of control over partitions, mountpoints and the like. This was not really an issue, as I am using a SOE and can Mount Volumes through VBScript.

The one issue that we had with mounting this specific Volume is that if a USB Drive or a Virtual CD/DVD drive is installed on the machine, it modifies the volume numbering scheme. The volume we were previously attempting to mount was Volume 3. This became Volume 4 in the even that another drive was connected, or a higher number depending on how the USB drive was partitioned.

Not a grand issue, but one that was overlooked by the Corporate boys when they released one of their imaging tools (the hidden volume is the Image volume). I modified their install script to use a bit more smarts when attempting to find the volume it needs.

Function GetImageVolumeNumber
   On Error Resume Next
   Const ForWriting = 2
   Const ForReading = 1
   Set oShell = CreateObject("WScript.Shell")
   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oFile = oFSO.OpenTextFile( 
      oShell.ExpandEnvironmentStrings("C:\Temp\dp.txt"),ForWriting,True )
   oFile.WriteLine("LIST VOLUME")
   set proc = oShell.Exec ("diskpart /s C:\Temp\dp.txt")
   Ouptut = ""
   Str = ""
   Do while Not proc.StdOut.AtEndOfStream
      Str = proc.StdOut.ReadLine
      If InStr(Str,"Volume") > 0 Then
         If Not (Mid(Str,10,3) = "###") Then
            DriveLetter = Mid(Str,16,1)
            VolumeNumber = Trim(Mid(Str,10,3))
            If StrComp(Mid(Str,20,5),"IMAGE")=0 Then
               GetImageVolumeNumber = VolumeNumber
               Exit Function
            End If
         End If
      End If
End Function

This function simply uses the output from DiskPart in order to find the number of the volume named “IMAGE”. This is then returned to the call point and can be used in place of the previous DiskPart calls to “SELECT VOLUME 3” and “ASSIGN MOUNT=C:\Temp\Image”. The only issue with this Shell Exec call is that it cannot be hidden, as then we cannot retrieve the output. This is not a real issue as the Console screen should just flash up and close quickly. Alternatively I could have fed the output into a text file and read it from that, but part of me is always interested in seeing new ways to do things, which was reading from StdOut in this instance.

So this leaves my MSI to be a shell that copies files to an “install” location, then runs a VBScript that mounts the volume and copies those files to the Image Drive. Not ideal, but the best solution I have at the moment. The Corporate guys are considering implementing this in the next version of the Imaging Tool, but in the meantime I will simply replace all the buggy files for my own Administrative Area.

Oh, and I know somebody is going to mention the Shell ExpandEnvironmentStrings call that is unneccessary. This is because it was originally using %temp%. I left it there for now in case I start using %temp% again. Then I can just do a find-replace for “C:\Temp” to “%Temp%” to return it to its previous functionality.

Cheers, Chris.

:, , , , ,

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!