Video Screencast Help

Evaluating WISE - help with custom action script

Created: 16 Mar 2011 | 3 comments

Hi Everyone,

I am in the process of evaluating WISE as a replacement for InstallShield and need help with converting an InstallShield script to a WISE script.

Here is the installshield script:

 /---------------------------------------------------------------------------
// OnBegin
//
// The OnBegin event is called directly by the framework after the setup
// initializes.
//---------------------------------------------------------------------------
function OnBegin()
 STRING szKey, szName, szValue;
    STRING svResult, svPath, svVersionNumber;
   NUMBER nvResult, nvType, nvSize;
begin  

    // Set the root key.
    RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE);  
   
    // Make sure Office is installed
    if ((RegDBKeyExist ("\\Software\\Microsoft\\Office\\12.0\\Excel") < 0) &&
        (RegDBKeyExist ("\\Software\\Microsoft\\Office\\14.0\\Excel") < 0)) then
        MessageBox ("Microsoft Excel 2007 or higher must be installed first", SEVERE);
        abort;
    endif;
   
 nvType = REGDB_STRING;
 szKey = "\\Software\\Microsoft\\Office\\14.0\\Excel\\InstallRoot";
 szName = "Path";
 if (RegDBGetKeyValueEx (szKey, szName, nvType, szValue, nvSize) < 0) then
  szKey = "\\Software\\Microsoft\\Office\\12.0\\Excel\\InstallRoot";
  szName = "Path";
  if (RegDBGetKeyValueEx (szKey, szName, nvType, szValue, nvSize) < 0) then
         MessageBox ("Unable to get Microsoft Office installation path", SEVERE);
         abort;
  endif;
 endif;
    FeatureSetTarget(MEDIA, "<LIBRARYDIR>", szValue ^ "\\Library\\Wisard");

    // Make sure the Rdb ODBC driver is installed
    nvResult = VerFindFileVersion("sqrdb3.dll", svPath, svVersionNumber);
  if (nvResult = FILE_NOT_FOUND) then
        MessageBox ("Oracle Rdb ODBC Driver version 3.3.1.0 or higher must be installed first", SEVERE);
        abort;
    endif;   
   
    nvResult = VerCompare("3.3.1.0", svVersionNumber, VERSION);   
    if (nvResult = GREATER_THAN) then
        MessageBox ("Oracle Rdb ODBC Driver version 3.3.1.0 or higher must be installed first", SEVERE);
        abort;
    endif;    

end;  

Thank You,

Tracy

Comments 3 CommentsJump to latest comment

EdT's picture

Is the move from Installshield to Wise something that is being forced upon you? Installshield remains an actively developed and updated product, whereas Wise has not received the level of investment and development it had in the past due to changing priorities within Symantec, and therefore lags in some areas.

However, WPS 8 remains a powerful product without much of the baggage that older versions of Installshield had to carry due to maintaining functional compatibility with their even older non-MSI packaging tools.

It is not clear what level of help you need with converting the Installshield scripts. Are you an experienced scripter with a good understanding of MSI technology, or a total newbie, or somewhere in between?

What your script appears to be doing is checking for several registry keys and displaying error messages if they are not found. Since Wise MSI technology supports several scripting languages, including wisescript, you could rewrite this using either VBScript, and the msgbox command, or Wisescript, using the Get Registry Key command and the Display Message command.

Frankly, I would also propose some serious rethinks of how you handle these dependencies - especially if you contemplate offering silent install capability. It would help us to know if you will be packaging for internal "corporate" use, or producing installs as a software vendor.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

RabbitWolf's picture

Thank you for your reply...

The move is not being forced on me. I am free to use what ever tool I like. I currently use InstallShield, but have had problems with them concerning their restrictive activation rules and their lack of customer service. They basically think they should be able to detrime how often you are able to modify your hardware. If you deactivate and then reactivate more times than they like, they assume you are trying to get around the EULA and won't allow you to reactivate the product.

While I am not an expert scripter, I do have some experience and have taken a crack at converting the code to vbscript:

     Function CompareFileVersions(version1, version2)
   
       Dim i
      
      Dim parts1
      Dim parts2
      
      Dim lastIndex
   
        On Error Resume Next
       
        CompareFileVersions = 0

        parts1 = split(version1, ".")
        parts2 = split(version2, ".")

        For i = 0 to 3
            If CInt(parts1(i)) > CInt(parts2(i)) Then
                CompareFileVersions = 1
            ElseIf CInt(parts1(i)) < CInt(parts2(i)) Then
                CompareFileVersions = -1
            End If
            If CompareFileVersions <> 0 Then Exit For
        Next
       
    End Function

    Dim fso
    Dim ws

    Dim excel12
    Dim excel14
   
    Dim version
    Dim windir
       
    On Error Resume Next
       
    Session.Property("ABORT") = "true"
   
    Set ws = CreateObject("WScript.Shell")
  
    excel12 = ws.RegRead("HKLM\Software\Wow6432Node\Microsoft\Office\12.0\Excel\InstallRoot\Path")
    excel14 = ws.RegRead("HKLM\Software\Wow6432Node\Microsoft\Office\14.0\Excel\InstallRoot\Path")
    
    If IsEmpty(excel12) And IsEmpty(excel14) Then
        Call MsgBox("Microsoft Excel 2007 or higher must be installed first", 48, "Wisard Excel Add-Ins")
        ws.Quit
    End If
   
    If Not IsEmpty(excel14) Then
      Session.TargetPath("INSTALLDIR2") = excel14 + "Library\Wisard"
    Else
      Session.TargetPath("INSTALLDIR2") = excel12 + "Library\Wisard"
    End If
   
    Set fso = CreateObject("Scripting.FileSystemObject")
   
    windir = ws.ExpandEnvironmentStrings("%SystemRoot%")
   
    If fso.FileExists(windir + "\system32\sqrdb3.dll") Then
        version = fso.GetFileVersion(windir + "\system32\sqrdb3.dll")
    ElseIf fso.FileExists(windir + "\sysWOW64\sqrdb3.dll") Then
        version = fso.GetFileVersion(windir + "\sysWOW64\sqrdb3.dll")
    Else
        Call MsgBox("Oracle Rdb ODBC Driver version 3.3.1.0 or higher must be installed first", 48, "Wisard Excel Add-Ins")
        ws.Quit
    End If
       
    If CompareFileVersions(version, "3.3.1.0") < 0 Then
        Call MsgBox("Oracle Rdb ODBC Driver version 3.3.1.0 or higher must be installed first", 48, "Wisard Excel Add-Ins")
        ws.Quit
    End If
   
    Session.Property("ABORT") = "false" 

  

 

How does this look?

This packaging is for corporate use. I don't need to worry about silent installations.

I have an additional question about the above script. I have some files that need to be installed in an Office subdirectory. I created a Path Variable called LIBRARYDIR to use in grouping the files needed by each Feature and set it to C:\Program Files (x86)\  since I have to set it to something. I then found that INSTALLDIR2 was set to [LIBRARYDIR]. You will notice that I expilictly set INSTALLDIR2 in my vbscript.

Will this result in the files being installed to the value I set INSTALLDIR2 to, or will the files be installed to the directory pointed to by LIBRARYDIR? If the answer is to the directory pointed to by LIBRARYDIR, how do I change the value of LIBRARYDIR.

Thank You,

Tracy

EdT's picture

The usual method of reading and writing properties from vbscript is as follows:

var = session.property("MYPROPERTY") - loads the content of MYPROPERTY into the vbscript variable var

session.property("MYPROPERTY") = var - loads the content of the vbscript variable var into the property MYPROPERTY

To set a directory table reference to the value in a property, you would use the "Set Directory" custom action.

I have not encountered any activation issues with Wise products as they don't have an activation process - once you enter a valid serial number, the product works, regardless of whether you are internet connected or not.

Have you considered using virtual machines for your test environment, with Installshield or Wise installed in the VM?  That would allow you to move the VM around different platforms - or does Installshield activation also break in these circumstances?

Support for Wise can be obtained through Symantec, and you can purchase a support agreement or pay by the call. These forums on connect are manned by other users of Wise products - we do not see any Symantec staff in here except on very rare occasions.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.