We login as "ImageBuild" to automatically install relevant apps before we rollout a PC to a user. If an install fails a folder is created in %systemroot%\InstalledProgs, such as OutlookFailed (always appended with "Failed".)

At the end of the install script, I use DirPlus to enumerate these "...failed" folders so that members of our team can investigate the failure and fix.

While this all works well, I don't believe my methodology is very robust referencing "8204". I only want output when there is a "...failed" folder present. If there are no "...failed" folders it doesn't show at all. Hence the reference to 8204 which means there is a result in the array(?).

I am a bit in the dark when it comes to arrays.

I would appreciate a critical eye to be cast over this script and suggestions would be welcome. It is not very elegant I believe.

Here's the code:

 Code:
; Pause login script if installs failed from Imagebuild
; -----------------------------------------------------
IF @USERID = "imagebuild"
       $iprogs = DIRPLUS("%systemroot%\InstalledProgs","/ad /m failed")
       $failedarray = vartype($iprogs)
       color w+/n
       IF $failedarray = 8204
          ? "ImageBuild - failed installs"
          ? "----------------------------"
       ENDIF  
       For Each $file In $iprogs
           $installfailed = substr($file,27)
           color w+/n ? "- " 
           color r+/n $installfailed
       Next
       IF $failedarray = 8204
          color w+/n
          ? "The above failed to install."
          ? "You will need to troubleshoot these."
          color g+/n ? "Press any key to continue the login script.."
          Get $
       ENDIF
ENDIF


Output as follows;

 Code:
ImageBuild - failed installs
----------------------------
- OutlookFailed
- WordFailed
The above failed to install.
You will need to troubleshoot these.
Press any key to continue the login script..




Edited by cavilrick (2009-03-02 10:12 PM)