Wednesday 30 May 2012

SCCM: Package returning error 259 how-to resolve

After attempting to deploy namely "AutoDesk" to an environment, we came across an issue where the SCCM Advertisement was returning error 259 in the CAS logs on clients. After investigations it was found that setup.exe was executing then spawning other processes while the setup thread was killed. Hence the agent was misreporting the install even though it was eventually successful. This is a small script I wrote to be executed via the program in the package for installs such as this. You must change the:
-strLogLoc (To the actual msi installer log to be monitored)
-cMD (To the actual installer command line)
-The if InStr check for the text in the log that is displayed with the main thread exit code(should be right at the end of the log) in this instance for AutoDesk I have used "]: MainEngineThread is returning" when it parses this line and grabs the "last" character of the line(the error code in this instance)


Don't attempt to modify the script other than this if you are not sure what you are doing, however feel free to ask a question and I shall reply when I have time. Hope this helps people google tells me alot of people have not been able to resolve this.


Sean

On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")


strCmd = objShell.ExpandEnvironmentStrings("%comspec%")


strScriptPath = objFSO.GetParentFolderName(wscript.ScriptFullName)
strLogLoc = "c:\Windows\Temp\Autodesk Revit Architecture 2012 Install (en-us).log"
'wscript.echo strScriptPath
If not right(strScriptPath,1) = "\" Then
strScriptPath = strScriptPath & "\"
End If
'wscript.echo strScriptPath




cMD = strCmd & " /c " & strScriptPath & "\Image\Setup.exe /qb /I Image\AutoDeskRevit_20.12_86a.ini"
'wscript.echo strCmd
'wscript.echo cMD
'Return = objShell.Run(cMD,0,False)


'Loop to wait for the log to be created to we check to see when it is finished installing
bLogExist = 1
While bLogExist = 1
    If objFSO.FileExists(strLogLoc) Then
wscript.echo "log exists"
bLogExist = 0
Else
wscript.echo "Waiting for log"
' do nothing just leave bool to 1
End if
    wscript.sleep 30000 'check every 30 seconds for the log file then once found continue
Wend 




'now check the loop in a loop to check when the MainEngine Thread is finished then return error code
bLogCheck = 1
strMainEngineThreadCode = ""
strErrorCode = 999
While bLogCheck = 1
Set objFile = objFSO.OpenTextFile(strLogLoc, 1, False, -1)
i = 0


Do Until objFile.AtEndOfStream
Redim Preserve arrLines(i)
arrLines(i) = objFile.readline
i = i + 1
Loop

For l = UBound(arrLines)-200 to UBound(arrLines)
If InStr(arrLines(l), "]: MainEngineThread is returning") Then
'strMainEngineThreadCode = arrLines(l)
wscript.echo arrLines(l)
for a=1 to len(arrLines(l))
strErrorCode = right(left(arrLines(l),a),1)
Next
bLogCheck = 0
End If
Next
ObjFile.Close
If bLogCheck = 1 Then
wscript.echo "Autodesk still installing"
Else
wscript.echo "Autodesk install completed with error code: " & strErrorCode
End If
If bLogCheck = 1 Then 
wscript.sleep 30000 ' sleep for 30 seconds then check the log again
End If
Wend



wscript.quit strErrorCode

9 comments:

  1. Hi,

    Thanks for the script and I've 2 concerns regarding this script,

    1.strLogLoc (To the actual msi installer log to be monitored)- As we are making use of the silent switches to install the application. Which Log file location do i need to pass here

    2.cMD = strCmd & " /c " & strScriptPath & "\Image\Setup.exe /qb /I Image\AutoDeskRevit_20.12_86a.ini"- In this do I need to replace the entire line or only from"\image\setup.exe

    ReplyDelete
  2. Depending on the specific application you need to capture that log. As to the specific return codes within the log that is also dependent on application. If anyone needs any help with this let me know and I will be glad to lend a hand

    ReplyDelete
    Replies
    1. This has been popping up continually over the last few days… every 5 mins or so.

      When I click on “view the message”, it refers to a vb script error on line 259 in the following file:
      C:\program files\ca\dsm\agent\units\00000001\uam\TrustedSitesInventory.vbs

      Delete
    2. I would say CA products are still as shit as they have always been in that case :)

      Delete
  3. After 2 years this post is still pulling in 500+ views a month. Shows that shit is as broken as it has always been :)

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Impressive script but seems over-engineered. I created this in batch and it worked for my deployment.

    "%~dp0Img\Setup.exe" /qb /I %~dp0Img\Config.ini /language en-us
    :SetupIsRunning
    timeout /t 30 /nobreak
    for /f %%x in ('tasklist /fi "imagename eq Setup.exe" /nh') do if %%x == Setup.exe goto SetupIsRunning

    ReplyDelete