Page 1 of 1 1
Topic Options
#192680 - 2009-03-02 10:10 PM DirPlus() utilisation - critique
cavilrick Offline
Fresh Scripter

Registered: 2005-11-15
Posts: 7
Loc: Auckland, New Zealand
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)

Top
#192683 - 2009-03-03 09:01 AM Re: DirPlus() utilisation - critique [Re: cavilrick]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, with your current switches, it should not return array unless there is a directory with a "failed" in the name.

so, I don't see the problem...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 581 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.058 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org