07 May 2012

Deploying Autodesk Revit Packages

Posted By: Mick Pletcher - 10:40 AM

Share

& Comment

Autodesk makes it very easy to create installation packages for deploying Revit software. The problem is that when executing these deployment packages through SMS/SCCM or integrating them into a build process, the package returns erroneous data and if it is in a build process, it causes errors because the build proceeds to install the next application when the Autodesk has not completed. This is caused because the setup.exe opens another instance of itself and then closes the original setup.exe, thereby making the deployment server or installation script think the installation is complete, when in essence, it is just beginning the installation.

To get around this, I wrote the following installation VBScript that executes the setup.exe, waits for 5 seconds, which is enough time for the new setup.exe to have appeared and the old one to have closed. That 5 seconds may need to be changed if it is an older machine. At that point, the script waits for the setup.exe process to disappear before it ends so the deployment server receives correct information as to when the deployment is complete.


 '*******************************************************************************  
 '     Program: Install.vbs  
 '      Author: Mick Pletcher  
 '        Date: 08 November 2010  
 '    Modified:  
 '  
 '     Program: Autodesk Revit  
 '     Version: 2012  
 ' Description: This will install Autodesk Revit Structural  
 '                 1) Define the relative installation path  
 '                 2) Create the Log Folder  
 '                 3) Install Current Version of Revit  
 '                 4) Install Workstation Monitor  
 '                 5) Cleanup Global Variables  
 '*******************************************************************************  
 Option Explicit

 REM Define Constants
 CONST TempFolder    = "c:\temp\"  
 CONST LogFolderName = "RevitStruct2012"  

 REM Define Global Variables  
 DIM LogFolder    : Set LogFolder    = Nothing  
 DIM RelativePath : Set RelativePath = Nothing  
 DIM ReturnCode   : ReturnCode       = "0"  

 REM Initialize Global Variables  
 LogFolder = TempFolder & LogFolderName & "\"  

 REM Define the relative installation path  
 DefineRelativePath()  
 REM Create the Log Folder  
 CreateLogFolder()  
 REM Install Current Version  
 InstallCurrentVersion()  
 REM Install Workshare Monitor  
 InstallWorkshareMonitor()  
 REM Cleanup Global Variables  
 GlobalVariableCleanup()  

 '*******************************************************************************  
 '*******************************************************************************  

 Sub DefineRelativePath()  

      REM Get File Name with full relative path  
      RelativePath = WScript.ScriptFullName  
      REM Remove file name, leaving relative path only  
      RelativePath = Left(RelativePath, InStrRev(RelativePath, "\"))  

 End Sub  

 '*******************************************************************************  

 Sub CreateLogFolder()  

      REM Define Local Objects  
      DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")  

      If NOT FSO.FolderExists(TempFolder) then  
           FSO.CreateFolder(TempFolder)  
      End If  
      If NOT FSO.FolderExists(LogFolder) then  
           FSO.CreateFolder(LogFolder)  
      End If 
 
      REM Cleanup Local Variables  
      Set FSO = Nothing  

 End Sub  

 '*******************************************************************************  

 Sub InstallCurrentVersion()  

      REM Define Local Constants  
      CONST Timeout  = 3000  
      CONST Timepoll = 500  
      CONST FileName = "setup.exe"  

      REM Define Local Objects  
      DIM oShell : Set oShell = CreateObject("Wscript.Shell")  
      DIM SVC    : Set SVC    = GetObject("winmgmts:root\cimv2")  

      REM Define Local Variables  
      DIM sQuery     : sQuery         = "select * from win32_process where name=" & Chr(39) & FileName & Chr(39)  
      DIM cproc      : Set cproc      = Nothing  
      DIM iniproc    : Set iniproc    = Nothing  
      DIM Install    : Set Install    = Nothing  
      DIM Parameters : Set Parameters = Nothing  

      REM Initialize Local Variables  
      Parameters = Chr(32) & "/qb /I" & Chr(32) & RelativePath &_  
                      "AdminImage\RST_64bit.ini"  
      Install    = RelativePath & "AdminImage\" & FileName & Parameters  

      REM Install Autodesk  
      oShell.Run Install, 1, True  
      REM Wait until Second Setup.exe closes  
      Wscript.Sleep 5000  
      Set cproc = svc.execquery(sQuery)  
      iniproc = cproc.count  
      Do While iniproc = 1  
           wscript.sleep 5000  
           set svc=getobject("winmgmts:root\cimv2")  
           sQuery = "select * from win32_process where name=" & Chr(39) & FileName & Chr(39)  
           set cproc=svc.execquery(sQuery)  
           iniproc=cproc.count  
      Loop  

      REM Cleanup Local Variables  
      Set cproc      = Nothing  
      Set iniproc    = Nothing  
      Set Install    = Nothing  
      Set oShell     = Nothing  
      Set Parameters = Nothing  
      Set sQuery     = Nothing  
      set svc        = Nothing  

 End Sub  

 '*******************************************************************************  

 Sub InstallWorkshareMonitor()  

      REM Define Local Objects  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  

      REM Define Local Variables  
      DIM MSI        : MSI        = Chr(32) & "workshare_monitor\worksharingmonitorforautodeskrevit2012_20110316_1624.msi"  
      DIM Log        : Log        = "WorkshareMonitor.log"  
      DIM Logs       : Logs       = Chr(32) & "/lvx" & Chr(32) & LogFolder & Log  
      DIM Parameters : Parameters = Chr(32) & "/qn /norestart"  
      DIM Install    : Install    = "msiexec.exe /i" & MSI & Logs & Parameters  

      oShell.Run Install, 1, True  

      REM Cleanup Local Variables  
      Set Install    = Nothing  
      Set Log        = Nothing  
      Set Logs       = Nothing  
      Set MSI        = Nothing  
      Set oShell     = Nothing  
      Set Parameters = Nothing  

 End Sub  

 '*******************************************************************************  

 Sub GlobalVariableCleanup()  

      Set LogFolder    = Nothing  
      Set RelativePath = Nothing  
      Set ReturnCode   = Nothing  

 End Sub  

About Mick Pletcher

My blog is here to help solve issues I have encountered and solved, publish scripts I have written, and educate others in understanding areas that are not well covered

0 comments:

Post a Comment

Copyright © 2013 Mick's IT Blogs™ is a registered trademark.