DS Job Shortcuts for PreReqs

This issue has been solved. See solution.
DaJuicemance's picture

I just posted this question under another section and am thinking I should have posted it here.  My aopolgies:

I am packaging an application that has a prereq of Microsoft Visual C++ 2005 Redistributable.  We have already packaged the Redistributable and have been using it (as a stand-alone job) in Production for quite some time.  In the new job I am creating, I have scripted a REG QUERY to look in the HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall key for "Microsoft Visual C++ 2005 Redistributable."  If found, the job exits with a custom EXIT CODE of 100 (the Redistributable is installed).  If not found, the job exits with a custom EXIT CODE of 111 (the Redistributable is NOT installed).  In the Return Codes dialog box, I have selected the Microsoft Visual C++ 2005 Redistributable job to run if EXIT CODE 111 is returned.

Everything works swimmingly ... with one exception.  After the called Microsoft Visual C++ 2005 Redistributable job completes, I have to go into the Console, right-click the computer in the new job, and select Retry Task in order for the application to be installed (a subsequent task).

I would prefer to have this job run from top to bottom without having to manually retry the tasks.  Any recommendations?

bhawver's picture

Job Conditions

What about looking for specific software to be installed after a inventory has been taken?

What I would do is the following:

Step one:  Console operator would right-click on machine and initiate a inventory request.
Step two:  Console operator waits a 20-30 seconds to allow for inventory request to complete and then kicks off conditioned jobs.

Step three:  The conditioned jobs would look to see if a specific app is installed via add/remove programs.  If it is not, it would execute the C++ distributable and move along down the line, if it is, it would execute the same jobs only without the C++ distributable package.

This would eliminate the need for custom error codes.  And still allow you to complete your objective that you listed above.

Hopefully, I explained it well enough, but if you need examples, I may be able to provide them based on what I run for hardware setups.

DaJuicemance's picture

Re: Job Conditions

Solution

BHawver - Thanks for the suggestion on Job Conditions; however, I am already using conditionals for the OS Type and Domain Membership.  I am filtering on (2) OS Types (XP & 2000) and (4) Domains.  As it stands, I've got (8) conditions.  In order to introduce the Application Description conditional, I would need to introduce another (2) conditions at a minimum bringing my total to (16) conditions ... on (9) DS's.

Your suggestion does provide me with a viable solution and, if I cannot find a way for the Main Job to continue after the Called Job runs, I may be relegated to using it.  My reluctance is more concerned with the amount of effort needed to change the job for any reason ... my REG QUERY job is a vbs file and I can easily use a ROBOCOPY script to copy a new REG QUERY out to the (9) DS's.  That way, I wouldn't have to touch each task in each conditional.  I guess you could say it's a personal preference.

I was thinking of using objFSO.CopyFolder to copy the files down to the local computer (as part of the subroutine below) and then install, but I like Altiris' copy feature better than objFSO.CopyFolder ... it's more reliable.

' Sub CppInsChk
 Sub CppInsChk ()
 Const HKLM = &H80000002
 Dim strAppNam    : strAppNam      = "Microsoft Visual C++ 2005 Redistributable"
 Dim objWshNet    : Set objWshNet  = WScript.CreateObject ("WScript.Network")
 Dim strComptr    : strComptr      = objWshNet.ComputerName
  Dim objReg       : Set objReg     = GetObject ("winmgmts:{impersonationLevel=Impersonate, (Restore)}!\\" & strComptr & "\root\default:StdRegProv")
 Dim strUninstKey : strUninstKey   = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
 Dim arrUninstSubKey, strUninstSubKey, strUninstSubKeyPth, strUninstAppDisNa   objReg.EnumKey HKLM, strUninstKey, arrUninstSubKey
   For Each strUninstSubKey In arrUninstSubKey
   strUninstSubKeyPth = strUninstKey & Chr(92) & strUninstSubKey
    objReg.GetStringValue HKLM, strUninstSubKeyPth, "DisplayName", strUninstAppDisNam
   If InStr (LCase (strUninstAppDisNam), LCase (strAppNam)) Then
     Exit Sub
   End If
   Next
  ' MsgBox "Microsoft Visual C++ 2005 Redistributable is not installed." CppIns
   WScript.Quit (107)
End Sub

Thinking of adding the below code snippet as another subroutine (re-edited after verifying efficacy):

' Sub CppIns
 Sub CppIns ()
   Dim strInsCom : strInsCom     = "%comspec% /c MsiExec /i C:\WINDOWS\DEPLOY\MS_Components\VCpp2005\vcredist.msi /quiet /norestart"
  Dim objFSO    : Set objFSO    = Wscript.CreateObject ("Scripting.FileSystemObject")
   Dim objWshShl : Set objWshShl = CreateObject ("WScript.Shell")
  If objFSO.FolderExists ("C:\WINDOWS\DEPLOY") Then
     If objFSO.FolderExists ("C:\WINDOWS\DEPLOY\MS_Components") Then
    If objFSO.FolderExists ("C:\WINDOWS\DEPLOY\MS_Components\VCpp2005") Then
     objFSO.CopyFolder "\\%DSServer%\eXpress\Apps\MS_Components\VCpp2005", "C:\WINDOWS\DEPLOY\MS_Components\VCpp2005", True
    Else
      objFSO.CreateFolder ("C:\WINDOWS\DEPLOY\MS_Components\VCpp2005")
     objFSO.CopyFolder "\\%DSServer%\eXpress\Apps\MS_Components\VCpp2005", "C:\WINDOWS\DEPLOY\MS_Components\VCpp2005", True
    End If
   Else
     objFSO.CreateFolder ("C:\WINDOWS\DEPLOY\MS_Components")
    objFSO.CreateFolder ("C:\WINDOWS\DEPLOY\MS_Components\VCpp2005")
     objFSO.CopyFolder "\\%DSServer%\eXpress\Apps\MS_Components\VCpp2005", "C:\WINDOWS\DEPLOY\MS_Components\VCpp2005", True
   End If
  Else
    objFSO.CreateFolder ("C:\WINDOWS\DEPLOY")
   objFSO.CreateFolder ("C:\WINDOWS\DEPLOY\MS_Components")
    objFSO.CreateFolder ("C:\WINDOWS\DEPLOY\MS_Components\VCpp2005")
   objFSO.CopyFolder "\\%DSServer%\eXpress\Apps\MS_Components\VCpp2005", "C:\WINDOWS\DEPLOY\MS_Components\VCpp2005", True
  End If
   objWshShl.Run strInsCom, 0, true
  End Sub
bhawver's picture

Tokens

Although I don't know how to do it, I would imagine that you can utilize custom tokens in your scripts to detect if a particular software is installed instead of conditions.  That may be easier?

DaJuicemance's picture

Re: Tokens

I like using the Tokens (e.g. - %DSServer% above) because when I copy this script out to the other (8) DS's in our environment, I don't have to edit them any further.  I then create a Run Script task with the following Run this script

Rem Check for Prereqs and install (if applicable)
Rem ReplaceTokens .\Apps\Application\MasterScriptPostedAbove-PreReqs.vbs .\Apps\Application\Scripts-Temp\%COMPNAME%-TokenReplacementScript-PreReqs.vbs
%DSSERVER%\eXpress\Apps\Application\Scripts-Temp\%COMPNAME%-TokenReplacementScript-PreReqs.vbs

This way, I just use a ROBOCOPY script to copy the exported job and the vbs script to the same location on my other (8) DS's, and then import the job on each of the (8) DS's.  Going forward, if I ever need to change the script (NOT change the Task), I simply rename the old script & copy the new one out using the name referenced by the job / task.

But I digress ... my original post was to find out if there was a way to make a called job / shortcut job / alias job (one which uses Altiris to push the C++ install files, then install C++ locally) go back to the original job making the call and proceed with the next Task.  The solution I've posted above is viable and has less "administrative overhead" as it pertains to ongoing Conditional maintenance, but uses the objFSO.CopyFolder method instead of Altiris' Copy File to.