I have a script that I use for installing MS updates on computers. I am implementing something to check actual file version, due to some of the updates not creating reg files when slipstreamed into the install. I wrote a function to perform what i need, and it works fine. When i move it into a different script (so it can be a more universal), it always says it cant find the file - even though I display the contents and they are fine. Here's a snippet of the script. Please let me know if you need more.
Here's how it flows. I call Script A. It then calls Script B for checking. Anytime an update is needed, Script E is called (and performs the update). It works in Script B, but not in Script E. I use all Calls and Returns.
Code:
Function UpdatedFileList()
$ArraySize = 0
$filename = "$ScriptDir\fileupdatelist.csv" ; This file is in the format: KB######,Filename,FileVersion
If Open(1,$filename) = 0
$line = ReadLine(1)
While @error = 0
$x = Left($line,8)
If $x = $KBNumber
$ArraySize = $ArraySize + 1
EndIf
$line = ReadLine(1)
Loop
$=Close(1)
EndIf
If $ArraySize == 0
Return
EndIf
Dim $array[$ArraySize-1,1]
$ArrayCount = 0
If Open(1,$filename) = 0
$line = ReadLine(1)
While @error = 0
$x = Left($line,8)
If $x = $KBNumber
; $=MessageBox("ArrayCount is $ArrayCount","$KBNumber",0)
$LastComma = InStrRev($line,',')
$array[$ArrayCount,0] = SubStr($line,10,$LastComma - 10)
$array[$ArrayCount,1] = Right($line, Len($line) - $LastComma)
$ArrayCount = $ArrayCount + 1
EndIf
$line = ReadLine(1)
Loop
$=Close(1)
EndIf
For $x = 0 to Ubound($array) ;$ArrayCount-1 ;
$FileNameCheck = $array[$x,0]
$FileVerCheck = $array[$x,1]
$=MessageBox($FileNameCheck + '-' + GetFileVersion($FileNameCheck),"$KBNumber",0)
; ? "$array[$x,0]-$FileNameCheck;$array[$x,1]-$FileVerCheck"
If GetFileVersion($FileNameCheck) < $FileVerCheck
$NeedUpdate = 'Y'
? "$FileNameCheck;$FileVerCheck"
EndIf
Next
$UpdatedFileList = $NeedUpdate
EndFunction