Page 1 of 1 1
Topic Options
#60110 - 2001-10-27 05:52 AM Dir() issues; Win2k works, NT4 doesn't.
Anonymous
Unregistered


In updating one of my scripts, I have added a couple more dir() functions. I have been doing my developement and testing on a win2k box, and everything works great. Before I considered it final, I tested it on an NT4 box, and I got an error. I am using Kix v4.0(RC3), but also verified the same issue with Kix v3.63. I narrowed the error down to dir(). I have to specify an index on the dir() that errors, where on the win2k box I don't. It seems that kix thinks I have a prior dir() still going, but I don't, as the win2k box runs the script fine. Is anyone familiar with this problem? Thanks!

In case you need an example, here is the code that's giving me problems. I have commented out chunks so the script will run without other dependent files.
You will need to create 2 files for the dir()'s to work:
SPSM_Web.mod and SPS_blah.ini
(The last file can be any SPS_*.ini, and the contents of either does not matter)
Also, you can alternate the comment from the 44th and 45th lines. The script as is should error on NT4, but not on win2k. If you comment the 44th line ($Rtn = Dir("SPSM_*.mod")) and uncomment the 45th line, nt4 will run it fine. Also, if you alternate the comment on the 98th and 99th lines, as well as the next Dir() lines, you will see the having an index fixes this.
Sorry about the lengthy post, but I am trying to be as thorough as possible for anyone willing to help me out. Thanks again!

-Morbid

code:

; **********************************
; **** ServerPS.kix v5.3 ****
; **** Check servers for Procs ****
; **** ****
; **** -Created by Scott Jones ****
; **** ****
; **** Date Started: 04.19.2001 ****
; **** Last Updated: 10.26.2001 ****
; **********************************

Break On

Color y+/n
CLS

$DimX = 54
$DimY = 26

Shell "%ComSpec% /c mode con: cols=" + $DimX + " lines=" + $DimY
Box(0, 0, $DimY - 1, $DimX - 2, "single") ; Outter edge


;//// Begin: Stuff \\\\
$Version = "v5.3"
$LogDir = "C:\Temp\ServerPS_Logs"
$Process = "DRWTSN32"
$Comment = ";"
$Sweep = 1
$StartDate = @DATE
$StartTime = @TIME
If $DelayTime < 1
$DelayTime = 15
EndIf
If $Alert <> 1
$Alert = 0
EndIf
$Tickr = 0
At($DimY - 1, 2) "["
At($DimY - 1, 12 + Len($Version)) "]"
Color c+/c
At($DimY - 1, 3) "ServerPS " + $Version
Color y+/n

$Rtn = Dir("SPSM_*.mod")
;$Rtn = "SPSM_Web.mod"
;If $Rtn = ""
; Box($DimY - 23, $DimX / 2 - 10, $DimY - 21, $DimX - 18, "double")
; Color r+/r
; At($DimY - 22, $DimX / 2 - 9) " No module found! "
; Goto "End"
;EndIf

$ModName = SubStr($Rtn, 6, Len($Rtn) - 9)

;$ModState = 0
;Call "SPSM_" + $ModName + ".mod"
;If $SPSDir = ""
; Box($DimY - 23, $DimX / 2 - 18, $DimY - 21, $DimX - 10, "double")
; Color r+/r
; At($DimY - 22, $DimX / 2 - 17) " Module not correctly configured! "
; Goto "End"
;EndIf

At($DimY - 1, $DimX - 13 - Len($ModName)) "["
At($DimY - 1, $DimX - 4) "]"
Color c+/c
At($DimY - 1, $DimX - 12 - Len($ModName)) "Module: " + $ModName
Color w+/c
At($DimY - 1, $DimX - 6 - Len($ModName)) ":"
Color y+/n


;// Begin: Configuration Menu \\
If $FileConf <> ""
Goto "DomainCheck"
EndIf
$a = SetTitle("ServerPS: Config Menu")
$Rtn = Dir("SPS_*.ini")
If $Rtn = ""
Box($DimY - 23, $DimX / 2 - 13, $DimY - 21, $DimX - 15, "double")
Color r+/r
At($DimY - 22, $DimX / 2 - 12) " No config files found! "
Goto "End"
EndIf

$Counter = 0
$Rtn = Dir("SPS_*.ini")
While $Rtn <> "" AND @ERROR = 0
$Counter = $Counter + 1
$Rtn = Dir()
Loop

Dim $ConfigName[$Counter]
Dim $ConfigTime[$Counter]
Dim $ConfigInUse[$Counter]

$z = 0
$Rtn = Dir("SPS_*.ini")
;$Rtn = Dir("SPS_*.ini",1)
While $z < $Counter AND $Rtn <> ""
$ConfigName[$z] = SubStr($Rtn, 5, Len($Rtn) - 8)
$ConfigTime[$z] = GetFileTime($Rtn)
$a = Open(1, $SPSDir + "lock_" + $ConfigName[$z], 2)
If $a = 32
$ConfigInUse[$z] = "Yes"
Else
$ConfigInUse[$z] = "No"
$a = Close(1)
EndIf
$z = $z + 1
$Rtn = Dir("")
; $Rtn = Dir("",1)
Loop

Box(0, 0, 2, $DimX - 2, "single") ; Top box
At(1,1) "Select configuration file (1-" + $Counter + "):"
At(4,3) "#"
At(4,7) "Config File"
At(4,23) "In-Use"
At(4, $DimX - 22) "Last Modified"

$z = 0
While $z < $Counter
At(5 + $z, 2) "( )"
If $ConfigInUse[$z] = "Yes"
Color r/n+
Else
Color w+/n
EndIf
At(5 + $z, 3) 1 + $z
If $ConfigInUse[$z] = "Yes"
Color r/n+
Else
Color g+/n
EndIf
At(5 + $z, 7) $ConfigName[$z]
At(5 + $z, 23) $ConfigInUse[$z]
At(5 + $z, $DimX - 22) $ConfigTime[$z]
Color y+/n
$z = $z + 1
Loop

:ConfigMenu
At(1, 33 + Len($Counter)) Get $z

Select
Case $z = Chr(3) OR $z = Chr(27)
Quit
Case $z > 0 AND $z <= $Counter
If $ConfigInUse[-1 + $z] = "Yes"
At(1, 33 + Len($Counter)) " "
Goto "ConfigMenu"
EndIf
$FileConf = $ConfigName[-1 + $z]
$FileTimeNew = $ConfigTime[-1 + $z]
Case 1
At(1, 33 + Len($Counter)) " "
Goto "ConfigMenu"
EndSelect

$z = 0
While $z <= $Counter
At(4 + $z, 2) " "
At(4 + $z, 7) " "
$z = $z + 1
Loop
;\\ End: Configuration Menu //


:DomainCheck
$a = Open(1, $SPSDir + "lock_" + $FileConf, 2)
If $a = 32
Box($DimY - 23, $DimX / 2 - 11, $DimY - 21, $DimX - 16, "double")
Color r+/r
At($DimY - 22, $DimX / 2 - 10) " Config file in use! "
Goto "End"
Else
$a = Close(1)
EndIf

If $FileTimeNew = ""
$FileTimeNew = GetFileTime("SPS_" + $FileConf + ".ini")
EndIf

$a = Open(1, "SPS_" + $FileConf + ".ini")
$Domain = ReadLine(1)
$a = Close(1)

$Title = "ServerPS $Version: $FileConf"
$FileTemp = "C:\Temp\" + $FileConf + "-" + @USERID + ".txt"
;\\\\ End: Stuff ////


At($DimY - 1, 2) "["
At($DimY - 1, 3 + Len($Title)) "]"
Color c+/c
At($DimY - 1, 3) $Title
Color y+/n

If Exist($LogDir) = 0
MD $LogDir
If @ERROR <> 0
Color r+/r
At(1,1) "Could not create Logs Dir..."
Goto "End"
EndIf
EndIf

$ModState = 1
Call "SPSM_" + $ModName + ".mod"

If $UserName <> ""
Box(0, 0, 2, $DimX - 2, "single") ; Top box
$User = $Domain + "\" + $UserName
Goto "PassGet"
EndIf


;//// Begin: User selection \\\\
$a = SetTitle("ServerPS: Select User")
Box(0, 0, 2, $DimX - 2, "single") ; Top box

$UserName = ""
$UserChr = ""
$UserAsc = 0
At(1,1) UCase($Domain) + " Username:"
Color y/n
At(2,1) "[Default = " + @USERID + "]"
Color y+/n

While $UserAsc <> 13
At(1, Len($Domain) + 12) " "
Color r+/n
At(1, Len($Domain) + 12) $UserName
At(1, Len($Domain) + Len($UserName) + 12) Get $UserChr
$UserAsc = Asc($UserChr)
Select
Case $UserAsc = 8
If Len($UserName) > 0
$UserName = SubStr($UserName, 1, Len($UserName) - 1)
EndIf
Case $UserAsc = 3 OR $UserAsc = 27
Quit
Case $UserAsc <> 13
$UserName = $UserName + $UserChr
EndSelect
Color y+/n
Loop

If Len($UserName) = 0
$UserName = @USERID
EndIf

Color y+/n
$User = $Domain + "\" + $UserName
At(0,0)
;\\\\ End: User selection ////


;//// Begin: Password section \\\\
$a = SetTitle("ServerPS: Enter Password")
Box(0, 0, 2, $DimX - 2, "single") ; Top box

:PassGet
$Password = ""
$Passwyrd = ""
$PassChr = ""
$PassAsc = 0
$PassLen = 0
At(1,1) UCase($User) + " Password:"

While $PassAsc <> 13
At(1, Len($User) + 12) " "
Color r+/n
At(1, Len($User) + 12) $Passwyrd
At(1, Len($User) + 12 + $PassLen) Get $PassChr
$PassAsc = Asc($PassChr)
Select
Case $PassAsc = 8
If $PassLen > 0
$Passwyrd = SubStr($Passwyrd, 1, $PassLen - 1)
$Password = SubStr($Password, 1, $PassLen - 1)
$PassLen = $PassLen - 1
EndIf
Case $PassAsc = 3 OR $PassAsc = 27
Quit
Case $PassAsc <> 13
$Passwyrd = $Passwyrd + "x"
$Password = $Password + $PassChr
$PassLen = $PassLen + 1
EndSelect
Color y+/n
Loop

At(1, Len($User) + 12) "(Verifying...) "
At(0,0)
$a = Open(1, "SPS_" + $FileConf + ".ini")
$Rtn = ReadLine(1)
$Rtn = ReadLine(1)
$Rtn = ReadLine(1)
$a = Close(1)
$a = "z"

:PassVerify
Use $a + ":" "\\" + $Rtn + "\c$" /user:$User /password:$Password
$z = @ERROR

At(1, Len($User) + 12) " "
Color r+/r
Select
Case $z = 0
Use $a + ":" /delete
Color g+/n
At(1, Len($User) + 12) "(Accepted)"
Case $z = 1326
At(1, Len($User) + 12) "(Invalid password!)"
Color y+/n
At(0,0)
Sleep 5
Goto "PassGet"
Case $z = 53
At(1, Len($User) + 12) "(Check server not found!)"
Goto "End"
Case $z = 67
At(1, Len($User) + 12) "(Check share invalid!)"
Goto "End"
Case $z = 85
If $a = "z"
$a = "x"
Goto "PassVerify"
Else
At(1, Len($User) + 12) "(Cannot verify password!)"
Goto "End"
EndIf
Case 1
At(1, Len($User) + 12) "(Unknown error!)"
Goto "End"
EndSelect
Color y+/n
At(0,0)
Sleep 1
;\\\\ End: Password section ////


$a = SetTitle("ServerPS: Launching...")
Big
At(4,3) "Server"
At(12,11) "Proc"
Small
At(18,42) "- $Version"
Color w+/n
At($DimY - 2, $DimX - 25) "-written by Scott Jones"
Color y+/n
At(0,0)
Sleep 2

GoSub "CnfRefresh1"


;//// Begin: Error arrays \\\\
$MaxErrors = $TotalCount
Global $ErrorIndex[$MaxErrors]
Global $ErrorHost[$MaxErrors]
Global $ErrorTime[$MaxErrors]
Global $ErrorPS[$MaxErrors]

$z = 0
While $z < $MaxErrors
$ErrorIndex[$z] = "9999999"
$ErrorHost[$z] = ""
$ErrorTIme[$z] = ""
$ErrorPS[$z] = ""
$z = $z + 1
Loop
;\\\\ End: Error arrays ////


;//// Begin: Prep Log File \\\\
$a = RedirectOutput($LogDir + "\" + $FileConf + "-" + SubStr(@DATE, 1, 4) + "." + SubStr(@DATE, 6, 2) + "." + SubStr(@DATE, 9, 2) + ".log")
?
? "--------"
? @TIME + " - ServerPS $Version started by " + @USERID + "."
$a = RedirectOutput("")
;\\\\ End: Prep Log File ////


;//// Begin: Main section \\\\
$DimX = 54
$DimY = 6

Shell "%ComSpec% /c mode con: cols=" + $DimX + " lines=" + $DimY
$a = SetTitle("[0] " + $Title)

Box($DimY - 2, 0, $DimY - 1, $DimX - 2, "single") ; Bottom Box
Box(0, $DimX - 30, 2, $DimX - 2, "single") ; Upper-right box
Box(0, 0, 2, 24, "single") ; Upper-left box
Box(2, 0, 4, $DimX - 2, "double") ; Current box

;Redraw Title
At($DimY - 1, 2) "["
At($DimY - 1, 3 + Len($Title)) "]"
Color c+/c
At($DimY - 1, 3) $Title
Color y+/n

Color g+/g
At(1,1) " " + $StartDate + " " + $StartTime + " "
At(1, $DimX - 29) " Servers: "
At(1, $DimX - 14) " Sweep: "
Color y+/g
At(1,13) "|"
At(1,39) "|"
Color g+/n
At(3,1) "Current:"
Color y+/n

At($DimY - 1, $DimX - 13) "[ ]"
Color c+/c
At($DimY - 1, $DimX - 12) "0 Errors"
Color y+/n

At($DimY - 1, Len($Title) + 6) "[ ]"
$Problems = 0
GoSub "SPSInfo"

$a = Open(5, $SPSDir + "lock_" + $FileConf, 5)
$ModState = 2
Call "SPSM_" + $ModName + ".mod"


:Top
GoSub "SPSInfo"
Color g+/g
At(1, $DimX - 19) $SrvCount
If $Sweep < 100
At(1, $DimX - 6) $Sweep
Else
At(1, $DimX - 6) ">99"
EndIf

Color y+/n
At(3,10) " "
$ProcNum = 0
$SrvNum = 0
While $SrvNum < $SrvCount
GoSub "Ticker"
If $ProcNum < $TotalCount
$ProcCount = 0
$z = 0
While $z < 1 AND @ERROR = 0 AND $ProcNum + $ProcCount < $TotalCount
If $MainServer[$ProcNum] = $MainServer[$ProcNum + $ProcCount]
$MainError[$ProcNum + $ProcCount] = 0
$ProcCount = $ProcCount + 1
Else
$z = 1
EndIf
Loop
Else
$ProcCount = 1
EndIf
$SrvCurrent = $SrvNum + 1

Color g+/n
At(3,10) "$SrvCurrent - " + $MainServer[$ProcNum] + " "
Color y+/n
At(0,0)
Shell "%ComSpec% /c pslist \\" + $MainServer[$ProcNum] + " -u " + $User + " -p " + $Password + " >" + $FileTemp
$a = Open(1, $FileTemp)
$z = 0
While $z < 6
$Rtn = ReadLine(1)
$z = $z + 1
Loop
If InStr($Rtn, "Failed") > 0
$a = Close(1)

Shell "%ComSpec% /c nbtstat -a " + $MainServer[$ProcNum] + " >" + $FileTemp
$a = Open(1, $FileTemp)
$Rtn = ReadLine(1)
$a = Close(1)
If InStr($Rtn, "found") > 0
$Message = "Server down"
Else
$Message = "Error grabbing ps"
EndIf

GoSub "LogDisplay"
Goto "MainSkip"
EndIf
$z = 0
While $z < 10
$Rtn = ReadLine(1)
$z = $z + 1
Loop
While $Rtn <> ""
If InStr($Rtn, $Process) > 0
$Message = $Process + " found"
$MainError[- 1 + $ProcNum + $ProcCount] = 1
GoSub "LogDisplay"
Else
$z = 0
While $z < $ProcCount
If InStr($Rtn, $MainProc[$ProcNum + $z]) > 0 AND $MainProc[$ProcNum + $z] <> ""
$MainError[$ProcNum + $z] = 1
$y = 0
While $y < $MaxErrors
If $ErrorHost[$y] = $MainServer[$ProcNum + $z] AND InStr($ErrorPS[$y], $MainProc[$ProcNum + $z]) > 0
$Message = $MainProc[$ProcNum + $z] + " restored"
GoSub "Sort"
$y = $MaxErrors
Else
$y = $y + 1
EndIf
Loop
$z = $ProcCount
Else
$z = $z + 1
EndIf
Loop
EndIf
$Rtn = ReadLine(1)
Loop
$a = Close(1)

$z = 0
While $z < $ProcCount
If $MainError[$ProcNum + $z] = 0 AND $MainProc[$ProcNum + $z] <> ""
$Message = $MainProc[$ProcNum + $z] + " not found"
GoSub "LogDisplay"
EndIf
$z = $z + 1
Loop

$y = 0
While $y < $MaxErrors
If $ErrorHost[$y] = $MainServer[$ProcNum]
Select
Case $ErrorPS[$y] = $Process + " found" AND $MainError[-1 + $ProcNum + $ProcCount] = 0
$Message = "DRWTSN32 cleared"
GoSub "Sort"
Case $ErrorPS[$y] = "Server down"
$Message = "Server back up"
GoSub "Sort"
Case $ErrorPS[$y] = "Error grabbing ps"
$Message = "Successfull ps"
GoSub "Sort"
EndSelect
EndIf
$y = $y + 1
Loop


:MainSkip
Del $FileTemp
$SrvNum = $SrvNum + 1
$ProcNum = $ProcNum + $ProcCount
Loop

$z = 0
While $z <> $ProcCount
$MainError[$z] = 0
$z = $z + 1
Loop

$Sweep = $Sweep + 1

GoSub "CnfRefresh1"
Goto "Top"
;\\\\ End: Main section ////

:End
At(0,0)
Sleep 5
Quit


; **** Sub-Routines ****

;//// Begin Subroutine: Logging to file \\\\
:LogDisplay
$m = 0
While $m < $MaxErrors
If $ErrorHost[$m] = $MainServer[$ProcNum] AND InStr($ErrorPS[$m], $Message) > 0
Goto "Log2"
EndIf
If $ErrorHost[$m] = $MainServer[$ProcNum] AND (($ErrorPS[$m] = "Server down" AND $Message = "Error grabbing ps") OR ($ErrorPS[$m] = "Error grabbing ps" AND $Message =

"Server down"))
$y = $m
$MessageTemp = $Message
GoSub "Sort"
$Message = $MessageTemp
EndIf
$m = $m + 1
If $m = $MaxErrors
$n = 0
While $n < $MaxErrors
If $ErrorHost[$n] = ""
$ErrorIndex[$n] = "$Sweep" + SubStr(@TIME, 1, 2) + SubStr(@TIME, 4, 2) + SubStr(@TIME, 7, 2)
$ErrorHost[$n] = $MainServer[$ProcNum]
$ErrorTime[$n] = @TIME
$ErrorPS[$n] = $Message
$Problems = $Problems + 1
$a = SetTitle("[" + $Problems + "] " + $Title)
At($DimY - 1, $DimX - Len("$Problems") - 13) "-["
Color c+/c
At($DimY - 1, $DimX - Len("$Problems") - 11) $Problems
Color y+/n

$ErrorMsg = $MainServer[$ProcNum]
While Len($ErrorMsg) < 16
$ErrorMsg = $ErrorMsg + " "
Loop

$a = RedirectOutput($LogDir + "\" + $FileConf + "-" + SubStr(@DATE, 1, 4) + "." + SubStr(@DATE, 6, 2) + "." + SubStr(@DATE, 9, 2) + ".log")
? @TIME + " - " + $ErrorMsg + " : " + $Message
$a = RedirectOutput("")
If $Alert = 1
Shell "%ComSpec% /c net send @WKSTA " + $MainServer[$ProcNum] + " : " + $Message + " >NUL"
EndIf

GoSub "SPSInfo"
Goto "Log2"
Else
$n = $n + 1
EndIf
Loop
EndIf
Loop

:Log2
Return
;\\\\ End Subroutine: Logging to screen and file ////

;//// Begin Subroutine: Sorting, clearing and redraw \\\\
:Sort
$ErrorIndex[$y] = "9999999"
$ErrorHost[$y] = ""
$ErrorTime[$y] = ""
$ErrorPS[$y] = ""
$Problems = $Problems - 1


;// Begin: Sorting \\
$Bad = 0
$s = 0
$t = 0
While $Bad < 2
If $s = 0
$Bad = 0
EndIf
$t = $s + 1
If $ErrorIndex[$s] > $ErrorIndex[$t]
$ErrorTemp1 = $ErrorIndex[$s]
$ErrorTemp2 = $ErrorHost[$s]
$ErrorTemp3 = $ErrorTime[$s]
$ErrorTemp4 = $ErrorPS[$s]

$ErrorIndex[$s] = $ErrorIndex[$t]
$ErrorHost[$s] = $ErrorHost[$t]
$ErrorTime[$s] = $ErrorTime[$t]
$ErrorPS[$s] = $ErrorPS[$t]

$ErrorIndex[$t] = $ErrorTemp1
$ErrorHost[$t] = $ErrorTemp2
$ErrorTime[$t] = $ErrorTemp3
$ErrorPS[$t] = $ErrorTemp4

$Bad = 1
Else
If $Bad = 0 AND $t = -1 + $MaxErrors
$Bad = 2
EndIf
EndIf
If $t = -1 + $MaxErrors
$s = 0
Else
$s = $s + 1
EndIf
Loop
;\\ End: Sorting //


$a = SetTitle("[" + $Problems + "] " + $Title)
At($DimY - 1, $DimX - Len("$Problems") - 13) "-["
Color c+/c
At($DimY - 1, $DimX - Len("$Problems") - 11) $Problems
Color y+/n

If $ProcNum = $TotalCount
$ErrorMsg = $TmpMainServer[$z]
Else
$ErrorMsg = $MainServer[$ProcNum]
EndIf
While Len($ErrorMsg) < 16
$ErrorMsg = $ErrorMsg + " "
Loop

$a = RedirectOutput($LogDir + "\" + $FileConf + "-" + SubStr(@DATE, 1, 4) + "." + SubStr(@DATE, 6, 2) + "." + SubStr(@DATE, 9, 2) + ".log")
? @TIME + " - " + $ErrorMsg + " : " + $Message
$a = RedirectOutput("")

GoSub "SPSInfo"

Return
;\\\\ End Subroutine: Sorting, clearing and redraw ////

;//// Begin Subroutine: Refresh Config list \\\\
:CnfRefresh1

If $Sweep > 1
$FileTimeOld = $FileTimeNew
$FileTimeNew = GetFileTime("SPS_" + $FileConf + ".ini")
If $FileTimeNew = $FileTimeOld
At(3,10) "(Done, Stalling for"
$z = 0
While $z <> $DelayTime
GoSub "Ticker"
$y = $DelayTime - $z
At(3,30) "$y Secs) "
At(0,0)
Sleep 1
$z = $z + 1
Loop
Return
EndIf
Color c+/n
At(3,10) "(Reloading Config: Stage 1)"
Color y+/n
At(0,0)
$TmpSrvCount = $SrvCount
$TmpTotalCount = $TotalCount

ReDim $TmpMainServer[$TmpTotalCount]
ReDim $TmpMainProc[$TmpTotalCount]

$z = 0
While $z < $TmpTotalCount
$TmpMainServer[$z] = $MainServer[$z]
$TmpMainProc[$z] = $MainProc[$z]
$z = $z + 1
Loop
Else
Global $TmpMainServer[1]
Global $TmpMainProc[1]
EndIf


;// Begin: Server/Process count \\
If $Sweep > 1
Color c+/n
At(3,35) "2"
Color y+/n
At(0,0)
EndIf
$SrvCount = 0
$ProcCount = 0
$a = Open(1, "SPS_" + $FileConf + ".ini")
$Rtn = ReadLine(1)
$Rtn = ReadLine(1)
While @ERROR = 0
$Rtn = ReadLine(1)
If $Rtn <> ""
If $Sweep = 1
GoSub "LoadMsg"
EndIf
$Server = $Rtn
If SubStr($Server, 1, 1) <> $Comment
$SrvCount = $SrvCount + 1
EndIf
While $Rtn <> ""
$Rtn = ReadLine(1)
If SubStr($Server, 1, 1) <> $Comment AND SubStr($Rtn, 1, 1) <> $Comment
$ProcCount = $ProcCount + 1
EndIf
Loop
EndIf
Loop
$a = Close(1)
$TotalCount = $ProcCount
;\\ End: Server/Process count //


;// Begin: Build Server/Process array \\
If $Sweep > 1
Color c+/n
At(3,35) "3"
Color y+/n
At(0,0)
EndIf
If $Sweep = 1
Global $MainServer[$TotalCount]
Global $MainProc[$TotalCount]
Global $MainError[$TotalCount]
Else
ReDim $MainServer[$TotalCount]
ReDim $MainProc[$TotalCount]
ReDim $MainError[$TotalCount]
EndIf
$a = Open(1, "SPS_" + $FileConf + ".ini")
$Rtn = ReadLine(1)
$Rtn = ReadLine(1)
$z = 0
While $z < $TotalCount
If $Sweep = 1
GoSub "LoadMsg"
EndIf
$Rtn = ReadLine(1)
$Server = $Rtn
While $Rtn <> ""
$Rtn = ReadLine(1)
If SubStr($Server, 1, 1) <> $Comment AND SubStr($Rtn, 1, 1) <> $Comment
$MainServer[$z] = $Server
$MainError[$z] = 0
$MainProc[$z] = $Rtn
$z = $z + 1
EndIf
Loop
Loop
$a = Close(1)
;\\ End: Build Server/Process array //


If $Sweep > 1
$z = 0
While $z < $TmpTotalCount
Color c+/n
At(3,35) "4 | " + $z + " - " + $TmpTotalCount + ")"
Color y+/n
At(0,0)

$y = 0
While $y < $TotalCount
If $TmpMainServer[$z] = $MainServer[$y] AND $TmpMainProc[$z] = $MainProc[$y]
Goto "CnfRefresh2"
EndIf
$y = $y + 1
Loop

$y = 0
While $y < $MaxErrors
If $ErrorHost[$y] = $TmpMainServer[$z] AND InStr($ErrorPS[$y], $TmpMainProc[$z]) > 0
$ProcNum = $TotalCount
$Message = "removed from list"
GoSub "Sort"
$y = $MaxErrors
Else
$y = $y + 1
EndIf
Loop

:CnfRefresh2
$z = $z + 1
Loop
EndIf

Return
;\\\\ End Subroutine: Refresh Config list ////

;//// Begin Subroutine: Output info to .sps file \\\\
:SPSInfo
Do
$a = RedirectOutput($SPSDir + "SPSo_" + $FileConf + ".sps", 1)
Until $a = 0
? $SrvCount
? $StartDate
? $StartTime
? $Sweep
? $Problems
$m = 0
While $m < $Problems
? $ErrorTime[$m]
? $ErrorHost[$m]
? $ErrorPS[$m]
$m = $m + 1
Loop
$a = RedirectOutput("")
Return
;\\\\ End Subroutine: Output info to .sps file ////

;//// Begin Subroutine: Loading Message \\\\
:LoadMsg

Select
Case $m = 0
$Loading = "lOADING"
Case $m = 1
$Loading = "LoADING"
Case $m = 2
$Loading = "LOaDING"
Case $m = 3
$Loading = "LOAdING"
Case $m = 4
$Loading = "LOADiNG"
Case $m = 5
$Loading = "LOADInG"
Case $m = 6
$Loading = "LOADINg"
EndSelect

Color c+/n
At($DimY - 5, $DimX / 2 - 3) $Loading
Color y+/n
At(0,0)

$m = $m + 1
If $m = 7
$m = 0
EndIf

Return
;\\\\ End Subroutine: Loading Message ////

;//// Begin Subroutine: Ticker \\\\
:Ticker

Select
Case $Tickr = 0
$Tick = "|"
Case $Tickr = 1
$Tick = "/"
Case $Tickr = 2
$Tick = "-"
Case $Tickr = 3
$Tick = "\"
EndSelect

Color y/n
At($DimY - 1, Len($Title) + 7) $Tick
Color y+/n
At(0,0)

If $Tickr = 3
$Tickr = 0
Else
$Tickr = $Tickr + 1
EndIf

Return
;\\\\ End Subroutine: Ticker ////



Top
#60111 - 2002-01-04 07:48 AM Re: Dir() issues; Win2k works, NT4 doesn't.
Anonymous
Unregistered


I am bringing up this issue again, because I am still having problems. Since my initial post, I have added more dir() functions and on win2k, I have had to add an index for each additional dir() I use. If I don't, it kills an array and sets its upper boundary to 276, but is really nothing, because I can't add one variable to the array. My problem grows now, because I am now forced to add the index for it to work with win2k, and have to remove an index for it to work with NT4 (which is completely opposite of my original issue). If someone has had similar issues, or if someone could test my sample script to validate this, I would be very appreciative. At the current standing, I have to have 2 different versions of my script, 1 for win2k and 1 for NT4. Thanks!
Top
#60112 - 2002-01-04 01:59 PM Re: Dir() issues; Win2k works, NT4 doesn't.
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
Morbid,
Did you tried it with Kix 4.01 ? (available on Kixtart.org download page, and no informations about it in you last post)
Also, be carefull as Dim and Redim arrays don't work in the same manner in Kixtart 4.00 final and greater than Kixtart 4.00 RCx
I will try to get a look at it this evening
_________________________
? getobject(Kixtart.org.Signature)

Top
#60113 - 2002-01-05 04:51 AM Re: Dir() issues; Win2k works, NT4 doesn't.
Anonymous
Unregistered


Thanks for your help... yeah, I get the exact same results with v3.63 up to 4.01. I had the same issue all the way up through the betas too. Plagued by other odd issues before, I've even verified that integer variables are integers and string variables are strings. Thanks!
Top
#60114 - 2002-01-05 07:32 PM Re: Dir() issues; Win2k works, NT4 doesn't.
Anonymous
Unregistered


I have similar problems in a large script with multiple dir() functions whereby the second dir() causes a variable to be overwritten in the 26th position. This happens on a W2K Pro workstation using Kix 4.01.

I was able overcome the problem by using indexes as follows: dir(,1) for the first function and dir(,0) for subsequent functions. Any other combination of indexes does now work. Go figure!!

Top
#60115 - 2002-01-05 08:18 PM Re: Dir() issues; Win2k works, NT4 doesn't.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
ArchieCall,
Could you provide some example code where this bug manifests? If this can be recreated, it should be posted in the Beta forum where Ruud is more likely to notice it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60116 - 2002-01-06 03:21 AM Re: Dir() issues; Win2k works, NT4 doesn't.
Anonymous
Unregistered


ArchieCall, with your multiple dir()'s, is it killing your arrays, or a variable? From the sound of it, it sounds like kix gets confused when you use a bunch of dir()'s in a script, and doesn't close them successfully, so you must index the next one. The only odd thing is that I get different results with the different versions of NT on the same script.

-Moribid

Top
#60117 - 2002-01-06 07:50 PM Re: Dir() issues; Win2k works, NT4 doesn't.
Anonymous
Unregistered


To: LLigeta and morbid

Variable $LogFQNIEError
Variable should be \\tol-team1\Login Record\T192168005175.ie

The message box at line 634 shows that the variable is OK at that line.

The message box at line 664 shows that the 21st position of the array has been changed from a character "c" to a character "d".

If you change the script so that lines 206 and 214 have an index of "1", then the variable is not overwritten in the 21st position!!

--- line 1 of script starts in next line ---
;===== login script 12/30/2001 - V9.2a - Archie Call
; Audit Sophos installation and display warning banners
; Uses \\Tol-Team1\Login Record as Central Folder for files
; Write login record to file T????????????.txt
; Synchronize time to Tol-Team1
; Write out T????????????.ie file if IE is not 6.0 or 5.5 SP2
; Update to IE 6.0 if T????????????.u60 exists
; Update to IE 5.5 SP2 if T????????????.u55 exists
; Update a 1505 Jeff user to W2K SP2 if T????????????.w05 exists
; If IISADMIN service is installed give warning and write out
; T????????????.adm file
; If W2K Pro and not Service Pack 2 then write out T????????????.SP2
; V8 - Loop back during Sophos Install check and try again
; V9.0 Various potential virus initiators.
; V9.1 Check for various virus file fragments
; V9.2 Check that InterCheck is active
; IE patches for 6.0 and 5.5 SP2
; TrackIt Audit runs based on control file on C: drive
; V9.2a Loop 6 times for Sophos Error
;====================================================================
break on
$BeginTicks = @TICKS

$BlankDir = ""

dim $HoldLogs[25]
$MaxLogs = 15
cls
$VersionNo = "V9.2a"
$Spaces20 = " "

;==== determine OS type
$ProductSuite = @ProductSuite

;==== exit if Terminal Server
if $ProductSuite = 16
quit
endif

$ProductType = @ProductType
$PWAge = @PWAge

$Workstation = 0
;==== determine Sophos Class
Select
case $ProductType = "Windows 95"
$SophosClass = "W95"
$Workstation = 1
case $ProductType = "Windows 98"
$SophosClass = "W95"
$Workstation = 1
case $ProductType = "Windows Me"
$SophosClass = "W95"
$Workstation = 1
case $ProductType = "Windows NT Workstation"
$SophosClass = "NT"
$Workstation = 1
case $ProductType = "Windows NT Server"
$SophosClass = "NT"
case $ProductType = "Windows NT Domain Controller"
$SophosClass = "NT"
case $ProductType = "Windows 2000 Professional"
$SophosClass = "NT"
$Workstation = 1
case $ProductType = "Windows 2000 Server"
$SophosClass = "NT"
case $ProductType = "Windows 2000 Domain Controller"
$SophosClass = "NT"
case $ProductType = "Windows XP Home Edition"
$SophosClass = "XP"
$Workstation = 1
case $ProductType = "Windows XP Professional"
$SophosClass = "XP"
$Workstation = 1
case $ProductType = "Windows XP Server"
$SophosClass = "XP"
case $ProductType = "Windows XP Domain Controller"
$SophosClass = "XP"
case 1
$SophosClass = "Cannot determine -- Error!"
EndSelect

;====quit if not workstation
If $Workstation = 0
quit
endif

$StartBanner = "Sophos " + $VersionNo + " audit starting"
$Selection = MessageBox($StartBanner,"",0,1)

;==== update local pc time from Tol-Tam server.
settime "\\tol-team1"

$LoginFolder = "\\Tol-team1\Login Record\"
$LoginToolsFolder = $LoginFolder + "tools\"


;==== get Windows Service Pack if W2K
$W2KWinErr = 0
$ServicePack = @CSD
$WinServicePack = "This is not a W2K PC"
if $ProductType = "Windows 2000 Professional"
$WinServicePack = $ServicePack
if $ServicePack = "Service Pack 2"
else
;--- set flag to indicate Service Pack error
$W2KWinErr = 1
endif
endif

;==== determine the Sophos InstalledBy entry in Registry
$InstalledBy = "Key not found"
if $SophosClass = "W95"
$InstalledBy = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Sophos\Sweep95","InstalledBy")
endif
if $SophosClass = "NT"
$InstalledBy = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Sophos\SweepNT","InstalledBy")
endif

;==== determine the Sophos SweepNet Object Name entry in Registry
$SweepNetObj = "Key not found"
if $SophosClass = "NT"
$SweepNetObj = ReadValue ("HKEY_LOCAL_MACHINE\system\CurrentControlSet\Services\SweepNet","ObjectName")
endif

;=== determine whether IISADMIN service is loaded
$FoundIISAdmin = 0
$Index = 0
:Loop1
$KeyToCheck = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\"
$KeyName = EnumKey($KeyToCheck,$Index)
if @ERROR = 0
$Index = $Index + 1
$CheckKey = ucase($KeyName)
if $CheckKey = "IISADMIN"
$FoundIISAdmin = 1
endif
goto Loop1
endif

;==== determine what version of Internet Explorer is installed
$IEVersion = ReadValue ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer","Version")
$IEVersionOK = 0
$IEVersionName = ""
select
case $IEVersion = "5.50.4807.2300"
$IEVersionOK = 1
$IEVersionName = "5.5SP2"
case $IEVersion = "6.00.2462.0000" or $IEVersion = "6.0.2462.0000"
$IEVersionOK = 1
$IEVersionName = "6.0"
case $IEVersion = "6.00.2479.0006" or $IEVersion = "6.0.2479.0006"
$IEVersionOK = 1
$IEVersionName = "6.0"
case $IEVersion = "6.00.2600.0000" or $IEVersion = "6.0.2600.0000"
$IEVersionOK = 1
$IEVersionName = "6.0"
endselect

;==== determine whether IE patches are loaded
$IEPatch = ""
if $IEVersionOK = 1
if $IEVersionName = "6.0"
$Key1 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\"
$Key2 = "{716E024F-7F74-47F3-B93B-9FF7F3CBF94C}"
$KeyToCheck = $Key1 + $Key2
$IEPatch = ReadValue ($KeyToCheck,"ComponentID")
endif
if $IEVersionName = "5.5SP2"
$Key1 = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\"
$Key2 = "{FA5F6B99-B5FC-4C24-8CBF-669DA55CFD62}"
$KeyToCheck = $Key1 + $Key2
$IEPatch = ReadValue ($KeyToCheck,"ComponentID")
endif
endif

$UserName = @userid
$FullName = @fullname
$WkSta = @WkSta
$Domain = @Domain
$Tcpip = @ipaddress0

;===== determine if Sophos installed
$SophosInstalled = 1
$LocalDrive = "c:"
$KeepLooping = 1
$NoLoops = 0


;=== check on Sophos - uses looping in case Sophos is updating at
; the same time.
Do

$FileName = $LocalDrive + "\progra~1\sophos~1\vdl.dat"
$VDLDate = GetFileTime($FileName)
$VDLDate = substr($VDLDate,1,10)
if len($VDLDate) = 0
$SophosInstalled = 0
endif

;==== if Sophos installed calc latest IDE file date
if $SophosInstalled = 1
$LatestTime = "1900/01/01"
$i = 1
$DirFiles = $LocalDrive + "\progra~1\sophos~1\*.ide"
$FileName = Dir("$DirFiles",0)
while $FileName <> "" and @ERROR = 0
$ShowName = $FileName
$Result = GetFileTime($LocalDrive + "\progra~1\sophos~1\" + $ShowName)
$FileTime = Substr($Result,1,10)
If $FileTime > $LatestTime
$LatestTime = $FileTime
endif
$FileName = dir("",0)
loop
endif

;===== calc days for Todays date
$TodayDate = @date
$YearToday = val(Substr($TodayDate,1,4))
$MonthToday = val(Substr($TodayDate,6,2))
$DayToday = val(Substr($TodayDate,9,2))
$DaysToday = ($YearToday * 365) + ($MonthToday * 30) + $DayToday

;====== calc days for Latest IDE date
$YearLatest = val(Substr($LatestTime,1,4))
$MonthLatest = val(Substr($LatestTime,6,2))
$DayLatest = val(Substr($LatestTime,9,2))
$DaysLatest = ($YearLatest * 365) + ($MonthLatest * 30) + $DayLatest

;======= calc days for VLD date
$YearVDL = val(Substr($VDLDate,1,4))
$MonthVDL = val(Substr($VDLDate,6,2))
$DayVDL = val(Substr($VDLDate,9,2))
$DaysVDL = ($YearVDL * 365) + ($MonthVDL * 30) + $DayVDL

;==== calc elapsed days for IDE and VDL
$ElapsedDaysIde = $DaysToday - $DaysLatest
$ElapsedDaysVDL = $DaysToday - $DaysVDL

;==== set virus warning flag if IDE > 22 days old or VDL > 75 days old
$ShowVirusWarning = 0
if $ElapsedDaysIDE > 22 or $ElapsedDaysVDL > 75
$ShowVirusWarning = 1
endif

;=== determine InterCheck status
$InterCheckErr = 1
$ShellLine = $LoginToolsFolder + "icstatus.exe /s"
shell $ShellLine
$ShellError = @ERROR
if $ShellError = 0
$InterCheckErr = 0
endif

;=== determine whether to exit loop
if $SophosInstalled = 1 and $ShowVirusWarning = 0 and $InterCheckErr = 0
;=== Sophos is OK -- you are done
$KeepLooping = 0
else
$NoLoops = $NoLoops + 1
if $NoLoops = 6
;=== looped 6 times -- you are done
$KeepLooping = 0
else
;=== wait 5 seconds and try again
$PauseBanner = "Re-checking Sophos: Loop " + $NoLoops
$Selection = MessageBox($PauseBanner,"",0,5)
cls
endif
endif

until $KeepLooping = 0

;======== if Sophos not installed then show Crital Alert
if $SophosInstalled = 0
$MsgText = "Warning!! Sophos Anti-Virus may not installed on your computer." + chr(10)
+ "" + chr(10)
+ "Please contact Systems ASAP!" + chr(10)
+ "Systems should install Sophos on this computer today." + chr(10)
+ "" + chr(10)
+ "You can use your computer -- however, do not open email attachments!" + chr(10)
+ "" + chr(10)
+ "UserName ===> " + chr(9) + $UserName + chr(10)
+ "FullName ===> " + chr(9) + $Fullname + chr(10)
+ "WkStation ==> " + chr(9) + $WkSta + chr(10)
+ "TcpipAddr ==> " + chr(9) + $Tcpip + chr(10)
+ "Domain =====> " + chr(9) + $Domain + chr(10)
+ "" + chr(10)
+ "Do not ignore this Critical Alert!"
$Selection = MessageBox($MsgText,"Anti-Virus Critical Alert!",0,30)
endif

if $SophosInstalled = 1 and $InterCheckErr = 1
$MsgText = ""
+ "The Sophos InterCheck Scanner (Red Lightning Bolt) is not Active on your computer!" + chr(10)
+ "" + chr(10)
+ "Inform Systems to update Sophos on your computer today." + chr(10)
+ "" + chr(10)
+ "You can use your computer -- however, do not open email attachments!" + chr(10)
+ "" + chr(10)
+ "Do not ignore this Critical Alert!"
$Selection = MessageBox($MsgText,"Anti-Virus Critical Alert!",0,30)
endif


if ($ShowVirusWarning = 1) and ($SophosInstalled = 1) and ($InterCheckErr = 0)
$MsgText = "Current Date (YYYY/MM/DD) =====> " + chr(9) + $TodayDate + chr(10)
+ "Sophos IDE Date (YYYY/MM/DD) ==> " + chr(9) + $LatestTime + chr(10)
+ "Sophos VDL Date (YYYY/MM/DD) ==> " + chr(9) + $VDLDate + chr(10)
+ "" + chr(10)
+ "Sophos Anti-Virus is installed on your computer, but it is out of date!!" + chr(10)
+ "" + chr(10)
+ "Inform Systems to update Sophos on your computer today." + chr(10)
+ "" + chr(10)
+ "You can use your computer -- however, do not open email attachments!" + chr(10)
+ "" + chr(10)
+ "UserName ===> " + chr(9) + $UserName + chr(10)
+ "FullName ===> " + chr(9) + $Fullname + chr(10)
+ "WkStation ==> " + chr(9) + $WkSta + chr(10)
+ "TcpipAddr ==> " + chr(9) + $Tcpip + chr(10)
+ "Domain =====> " + chr(9) + $Domain + chr(10)
+ "" + chr(10)
+ "Do not ignore this Warning!"
$Selection = MessageBox($MsgText,"Anti-Virus Warning!",0,30)
endif

if $FoundIISAdmin = 1
$MsgText = "The Internet Information Server service was found on your computer!" + chr(10)
+ "" + chr(10)
+ "This service can be a source of viruses and is subject to outside attack." + chr(10)
+ "" + chr(10)
+ "Contact Systems to have this service removed!" + chr(10)
+ "" + chr(10)
+ "You can use your computer -- however the service must be removed today!" + chr(10)
$Selection = MessageBox($MsgText,"Internet Information Server Warning!",0,30)
endif


;==== write login record
cls

;===Pad TcpIp with zeros
$LogFileName = "T"
for $ii = 1 to 4
$FragOct = substr($TcpIP,($ii-1)*4+1,3)
$FragOct = "000" + ltrim($FragOct)
$F1 = len($FragOct) - 2
$FragOct = substr($FragOct,$F1,3)
$LogFileName = $LogFileName + $FragOct
next
$TCPSegment = left($LogFileName,10)

$AutoexecBat = "c:\autoexec.bat"
$LogFQN = $LoginFolder + $LogFileName + ".txt"
$LogFQNIEError = $LoginFolder + $LogFileName + ".ie"
$LogFQNError = $LoginFolder + $LogFileName + ".err"
$LogFQNIEUpdate55 = $LoginFolder + $LogFileName + ".u55"
$LogFQNIEUpdate60 = $LoginFolder + $LogFileName + ".u60"
$LogFQNIIS = $LoginFolder + $LogFileName + ".adm"
$LogFQNW2KWin = $LoginFolder + $LogFileName + ".sp2"
$LogFQNW2KSP205 = $LoginFolder + $LogFileName + ".w05"
$LogFQNFoundFrag = $LoginFolder + $LogFileName + ".frg"

$LogFQNIEPatchError = $LoginFolder + $LogFileName + ".pat"
$LogFQNIEPatch55 = $LoginFolder + $LogFileName + ".p55"
$LogFQNIEPatch60 = $LoginFolder + $LogFileName + ".p60"
$TrackItLocation = $LoginToolsFolder + "TrackItLoc.txt"
$TrackItLocalLoc = "c:\TrackItLast.Txt"

;--- read the TrackIt Control File
$x = open(2,$TrackItLocation,2)
$Lin = readline(2)
while @Error = 0
$TheLoc = $Lin
if left($TheLoc,10) = $TCPSegment
$lenl = len($TheLoc)
$SegmentLoc = right($TheLoc,$lenl-12)
$SegmentLoc = ucase(trim($SegmentLoc))
endif
$Lin = readline(2)
loop
$x = close(2)

;==== if previous log file exists then stack previous logins into array
if Exist($LogFQn)
$x = open(1,$LogFQN,2)
$Lin = readline(1)
$L1 = 1
$InLogs = 0
while @Error = 0
$TestHead1 = substr($Lin,1,10)
if $TestHead1 = "----------"
$InLogs = 1
endif
if $InLogs = 1
$HoldLogs[$L1] = $Lin
$L1 = $L1 + 1
endif
$Lin = readline(1)
loop
$L1 = $L1 - 2
else
$x = Open(1,$LogFQN,5)
for $iiii = 1 to 3
$TheLine = "Fixed Information" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
next
endif
$x = close(1)

del $LogFQN

if open(1,$LogFQN,5) = 0
;=== write the Fixed infor for the PC
$TheLine = "KixStart Version Number: " + $VersionNo + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "TCP/IP: " + $TcpIp + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "Computer: " + $WkSta + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "Domain: " + $Domain + " User: " + $UserName + " - " + $FullName + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "ProductType: " + $ProductType +
" Sophos Class: " + $SophosClass + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "ProductSuite: " + $ProductSuite + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "PWAge: " + $PWAge + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "Sophos VDL Date: " + $VDLDate + " Days old: " +
$ElapsedDaysVdl + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$TheLine = "Sophos Lastest IDE Date: " + $LatestTime + " Days old: " +
$ElapsedDaysIde + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

;----- determine sophos status
Select
case $SophosInstalled = 0
$SophosStatus = "Sophos not installed"
$SophosStatusCode = 0
case $ShowVirusWarning = 1
$SophosStatus = "Sophos is too old!!"
$SophosStatusCode = 0
case 1
$SophosStatus = "Sophos is current!"
$SophosStatusCode = 1
EndSelect

$TheLine = "Sophos Age Status: " + $SophosStatus + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

if $InterCheckErr = 1
$TheLine = "Sophos InterCheck Status: Inactive or not installed" + chr(13) + chr(10)
$SophosStatusCode = 0
else
$TheLine = "Sophos InterCheck Status: Active" + chr(13) + chr(10)
endif
$x = WriteLine(1,$TheLine)

$TheLine = "Sophos Installed By key: " + $InstalledBy + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

$TheLine = "Sophos SweepNet Account: " + $SweepNetObj + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)


$IEStatus = "Not protected!!"
if $IEVersionOK = 1
$IEStatus = "Version is protected."
endif
$TheLine = "IE Version: " + $IEVersion + " IE Status: " + $IEStatus + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

if $IEPatch = ""
$IEPatchStatus = "IE Patch MS01-058 (Q313675) is not installed!!."
else
$IEPatchStatus = "IE Patch MS01-058 (Q313675) is installed."
endif
$TheLine = "IE Patch Status: " + $IEPatchStatus + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

$IISAdmin = "IISAdmin Service is not loaded."
if $FoundIISAdmin = 1
$IISAdmin = "IISAdmin service is loaded!!"
endif
$TheLine = $IISAdmin + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

$ServicePackMessage = "Windows 2000 Service Pack: " + $WinServicePack
$TheLine = $ServicePackMessage + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

;=== check for various virus fragments
$FoundFragments = 0
$TheLine = "==== Check for various virus fragments ====" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
;--- nimda check
if Exist ("c:\admin.dll")
$FoundFragments = 1
$TheLine = " ---> Nimda fragment c:\admin.dll exists!!! " + chr(13) + chr(10)
else
$TheLine = " Nimda fragment c:\admin.dll not found." + chr(13) + chr(10)
endif
$x = WriteLine(1,$TheLine)
;--- sircam check
$RC = keyexist ("HKEY_LOCAL_MACHINE\software\sircam")
if $RC = 1
$FoundFragments = 1
$TheLine = " ---> Sircam fragment HKLM\software\sircam exists!!! " + chr(13) + chr(10)
else
$TheLine = " Sircam fragment HKLM\software\sircam not found." + chr(13) + chr(10)
endif
$x = WriteLine(1,$TheLine)


;=== write out HKLM Run values
$TheLine = "=== \HKLM\software\microsoft\windows\currentversion\run ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = 0
$KeyToCheck = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
:LoopN1
$KeyValueName = EnumValue($KeyToCheck,$Index)
if @ERROR = 0
$ValueData = ReadValue($KeyToCheck, $KeyValueName)
$NoSpaces = 21 - len($KeyValueName)
if $NoSpaces < 1
$NoSpaces = 2
endif
$KeyValueName1 = " " + $KeyValueName + substr($Spaces20,1,$NoSpaces)
$TheLine = $KeyValueName1 + $ValueData + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = $Index + 1
goto LoopN1
endif


;=== write out HKLM RunServices values
$TheLine = "=== \HKLM\software\microsoft\windows\currentversion\runservices ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = 0
$KeyToCheck = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices"
:LoopN2
$KeyValueName = EnumValue($KeyToCheck,$Index)
if @ERROR = 0
$ValueData = ReadValue($KeyToCheck, $KeyValueName)
$NoSpaces = 21 - len($KeyValueName)
if $NoSpaces < 1
$NoSpaces = 2
endif
$KeyValueName1 = " " + $KeyValueName + substr($Spaces20,1,$NoSpaces)
$TheLine = $KeyValueName1 + $ValueData + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = $Index + 1
goto LoopN2
endif

;=== write out HKCU Run values
$TheLine = "=== \HKCU\software\microsoft\windows\currentversion\run ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = 0
$KeyToCheck = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
:LoopN4
$KeyValueName = EnumValue($KeyToCheck,$Index)
if @ERROR = 0
$ValueData = ReadValue($KeyToCheck, $KeyValueName)
$NoSpaces = 21 - len($KeyValueName)
if $NoSpaces < 1
$NoSpaces = 2
endif
$KeyValueName1 = " " + $KeyValueName + substr($Spaces20,1,$NoSpaces)
$TheLine = $KeyValueName1 + $ValueData + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = $Index + 1
goto LoopN4
endif

;=== write out HKCU RunServices values
$TheLine = "=== \HKCU\software\microsoft\windows\currentversion\runservices ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = 0
$KeyToCheck = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices"
:LoopN5
$KeyValueName = EnumValue($KeyToCheck,$Index)
if @ERROR = 0
$ValueData = ReadValue($KeyToCheck, $KeyValueName)
$NoSpaces = 21 - len($KeyValueName)
if $NoSpaces < 1
$NoSpaces = 2
endif
$KeyValueName1 = " " + $KeyValueName + substr($Spaces20,1,$NoSpaces)
$TheLine = $KeyValueName1 + $ValueData + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = $Index + 1
goto LoopN5
endif

;=== write out \hkcr\exefile\shell\open\command values
$TheLine = "=== \hkcr\exefile\shell\open\command ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = 0
$KeyToCheck = "HKEY_CLASSES_ROOT\exefile\shell\open\command"
:LoopN3
$KeyValueName = EnumValue($KeyToCheck,$Index)
if @ERROR = 0
$ValueData = ReadValue($KeyToCheck, $KeyValueName)
$NoSpaces = 21 - len($KeyValueName)
if $NoSpaces < 1
$NoSpaces = 2
endif
$KeyValueName1 = " " + $KeyValueName + substr($Spaces20,1,$NoSpaces)
$TheLine = $KeyValueName1 + $ValueData + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Index = $Index + 1
goto LoopN3
endif

;---- shell= in System.ini
$ShellEquals = ReadProfileString("system.ini", "boot", "shell")
$TheLine = "=== system.ini: [boot] shell= " + $ShellEquals + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

;---- run= in Win.ini
$ShellEquals = ReadProfileString("win.ini", "windows", "run")
$TheLine = "=== win.ini: [windows] run= " + $ShellEquals + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

$Banner1 = "Value of LogFQNIEError is " + $LogFQNIEError
$Selection = MessageBox($Banner1,"",0,0)

;--- dir of start programs
if $SophosClass = "W95"
$TheLine = "=== \windows\startmenu\programs\startup ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$DirFiles = $LocalDrive + "\windows\startm~1\programs\startup\*.*"
$FileName = Dir("$DirFiles",0)
while $FileName <> "" and @ERROR = 0
if $FileName <> "." and $FileName <> ".."
$TheLine = " " + $FileName + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
endif
$FileName = dir("",0)
loop
else
$TheLine = "=== \docume~1\alluse~1\startmenu\programs\startup ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$DirFiles = $LocalDrive + "\docume~1\alluse~1\startm~1\programs\startup\*.*"
$FileName = Dir("$DirFiles",0)
while $FileName <> "" and @ERROR = 0
if $FileName <> "." and $FileName <> ".."
$TheLine = " " + $FileName + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
endif
$FileName = dir("",0)
loop
endif

$Banner1 = "Value of LogFQNIEError is " + $LogFQNIEError
$Selection = MessageBox($Banner1,"",0,0)

;--- Internet Explorer start page
$IEStartPage = ReadValue ("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main","Start Page")
$TheLine = "IE Start Page: " + $IEStartPage + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

;--- write out autoexec.bat file
$TheLine = "=== Autoexec.bat file ===" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$x = open(2,$AutoexecBat,2)
$Lin = readline(2)
while @Error = 0
$TheLine = " " +$Lin + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$Lin = readline(2)
loop
$x = close(2)


;--- calc total running time of script.
$ScriptSecs = @TICKS - $BeginTicks + 1500
$RunSecs = "$ScriptSecs"
$lens = len($RunSecs)
$TTSecs = substr($RunSecs,1 , $lens - 3) + "." + substr($RunSecs, $lens - 3, 3)
$TheLine = "Running time: " +$TTSecs + " seconds" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)

;---- write the variable logon times
$TheLine = "--------------------------" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
;=== write variable login records
$TheLine = $TodayDate + " " + @Time + " " + $UserName + " " + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
for $iiii = 2 to $L1
if $iiii <= $MaxLogs
$TheLine = $HoldLogs[$iiii] + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
endif
next
$TheLine = "==========================" + chr(13) + chr(10)
$x = WriteLine(1,$TheLine)
$x = close(1)
endif


;cls
;? $LogFQN
;? $LogFQNIEError
;? $LogFQNError
;? $LogFQNIEUpdate55
;? $LogFQNIEUpdate60
;? $LogFQNIIS
;? $LogFQNW2KWin
;? $LogFQNW2KSP205
;? $LogFQNFoundFrag
;gets $eee

;==== write Sophos error file
if $SophosStatusCode = 0
copy $LogFQN $LogFQNError
else
if exist($LogFQNError)
del $LogFQNError
endif
endif

;==== write IE Explorer error file
if $IEVersionOK = 0
copy $LogFQN $LogFQNIEError
else
if exist($LogFQNIEError)
del $LogFQNIEError
endif
endif

;==== write IE Explorer patch file
if $IEPatch = "" and $IEVersionOK = 1
copy $LogFQN $LogFQNIEPatchError
else
if exist($LogFQNIEPatchError)
del $LogFQNIEPatchError
endif
endif

;==== write IIS Service error file
if $FoundIISAdmin = 1
copy $LogFQN $LogFQNIIS
else
if exist($LogFQNIIS)
del $LogFQNIIS
endif
endif

;==== write W2K Windows Service Pack error file
if $W2KWinErr = 1
copy $LogFQN $LogFQNW2KWin
else
if exist($LogFQNW2KWin)
del $LogFQNW2KWin
endif
endif

;==== write found virus fragments file
if $FoundFragments = 1
copy $LogFQN $LogFQNFoundFrag
else
if exist($LogFQNFoundFrag)
del $LogFQNFoundFrag
endif
endif

;=== show OK Box
if $SophosStatusCode = 1
$OKMessage = "Sophos " + $VersionNo + " audit results" + chr(10)
+ chr(10) + " PC is OK"
$Selection = MessageBox($OKMessage,"",0,1)
endif

;====== update IE to Ver 5.5 Sp2
if exist($LogFQNIEUpdate55)
del $LogFQNIEUpdate55
if exist($LogFQNIEPatchError)
del $LogFQNIEPatchError
endif
$Update55sp2 = "\\hmibdc2\bdc2_d\build\cleanup\ie5setupsp2.exe"
run $Update55sp2
quit
endif

;====== update IE to Ver 6.0
if exist($LogFQNIEUpdate60)
del $LogFQNIEUpdate60
if exist($LogFQNIEPatchError)
del $LogFQNIEPatchError
endif
$Update60 = "\\hmibdc2\bdc2_d\build\cleanup\ie6setup.exe"
run $Update60
quit
endif

;====== update IE Ver 5.5 Sp2 with patches
if exist($LogFQNIEPatch55)
del $LogFQNIEPatch55
$Patch55 = "\\tol-team1\build\iepatch\5.5\q313675.exe"
run $Patch55
quit
endif

;====== update IE Ver 6.0 with patches
if exist($LogFQNIEPatch60)
del $LogFQNIEPatch60
$Patch55 = "\\tol-team1\build\iepatch\6.0\q313675.exe"
run $Patch55
quit
endif

;====== update W2K Pro to SP2
if $ProductType = "Windows 2000 Professional"
if exist($LogFQNW2KSP205)
del $LogFQNW2KSP205
$UpdateSP2 = "\\hmibdc2\bdc2_d\build\sp2.bat"
run $UpdateSP2
quit
endif
endif


;====== run TrackIt if more than 45 days since last run
if $SegmentLoc <> "NOAUDIT"
$DaysTrack = $DaysToday - 200
if exist($TrackItLocalLoc)
;======= calc elapsed days for trackit date
$TrackItDate = getfiletime($TrackItLocalLoc)
$YearTrack = val(Substr($TrackItDate,1,4))
$MonthTrack = val(Substr($TrackItDate,6,2))
$DayTrack = val(Substr($TrackItDate,9,2))
$DaysTrack = ($YearTrack * 365) + ($MonthTrack * 30) + $DayTrack
endif
$ElapsedDaysTrack = $DaysToday - $DaysTrack

if $ElapsedDaysTrack > 45
$StartBanner = "TrackIt Audit will run for a couple of minutes." + chr(10)
+ "" + chr(10)
+ "Select OK and then let TrackIt Audit run." + chr(10)
+ "Do not close the TrackIt Audit prematurely!"
$Selection = MessageBox($StartBanner,"TrackIt Info Message",0,8)
$TrackItAudit = $SegmentLoc + "audit32.exe"
shell $TrackItAudit
$StartBanner = "TrackIt Audit Completed Sucessfully"
$Selection = MessageBox($StartBanner,"",0,3)
del $TrackItLocalLoc
if open(2,$TrackItLocalLoc,5) = 0
$TheLine = "dummy info"
$x = WriteLine(2,$TheLine)
endif
$x = close(2)
endif
endif

cls

quit

Top
#60118 - 2002-01-06 11:19 PM Re: Dir() issues; Win2k works, NT4 doesn't.
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
YIKES! I was hoping you could toss together a few lines to show it's repeatable, not post over 600 lines! I'm a diehard NotePad user. No line numbers there.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#60119 - 2002-01-07 04:49 PM Re: Dir() issues; Win2k works, NT4 doesn't.
Anonymous
Unregistered


The script does not seem to give problems until it gets large. I tried for over two hours to get the problem to happen with only small snippits of code.

Sorry for the large post.

Top
#60120 - 2002-01-10 07:08 PM Re: Dir() issues; Win2k works, NT4 doesn't.
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
how big are the directory trees in question? if not to big you might want to try this UDF.

DirPlus() - a recursive dir tool

Bryce

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.059 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

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