"Jack" <j.baltus@xxxxxx> wrote in message
news:41b96$49e772f2$5ed32516$8586@xxxxxx
> Can anybody help me with a script
> I want if a one file exist then go to a select statement, and do somthing
> But i don`t no how It is difficult to write code when the solution does not follow more or less
automatically from the description of the problem. It also seems to me that
you are confusing what you want as a result with how you think it might be
coded.
> Option Explicit
> On Error Resume Next
> Dim arrScript, Array1, BtnCode, WshShell, FileName, FVersion, Script
> Dim Lcomputer, Msg, McShieldPath, NewDATVer, Nwrk, path, f,
> StartDir,sfncLib
> Dim OldDatVer, strDC, strVersion, sVirDefVer, verify, RegistryValue,
> VsInst80, VsInst85
> Dim strNextLine, Lineread, sTmpDir, Arraystr, infile, objTextFile,
> scommand
> Dim fso:
> CONST CONST_QUIT_MAIN = -99
> Const ForReading = 1
> Set fso = WScript.CreateObject("Scripting.FileSystemObject")
> Set Nwrk = WScript.CreateObject("WScript.Network")
> Set WshShell = WScript.CreateObject("WScript.Shell")
> Lcomputer = Nwrk.ComputerName
> Verify = 0
>
> VsInst80 = fso.FileExists("C:\Programs\Networ~1\VirusScan\Mcshield.exe") in this if-else-endif block:
> If verify = "1" then WScript.Echo "vsinst80 = " & vsinst80 Else
> WScript.Echo "vsinst80 = " & vsinst80 End If The FileExists method returns a boolean value, i.e. one which is either true
or false. The fact that the false and true values are represented by
quantites that can be compared to some numeric equivalents (or their string
equivalents) is a red herring of no value. In fact you have it wrong here as
verify will never have the value 1. Although a value of 1 is treated as true
when cast to a boolean, when a truly boolean result is returned, a true
value will be represented as -1.
Instead of [if verify = "1"] I'd recommend you use [if verify].
But that is not the only problem here. The same statement is executed
regardles of the value being tested. You could as easily replace these
statements with:
WScript.Echo "vsinst80 = " & vsinst80
By a strange twist of fate, your incorrect method for testing for the
existence of a file is nullified by the fact that, in this case, it makes no
difference.
> VsInst85 = fso.FileExists("C:\Programs\Mcafee\VirusScan\Mcshield.exe")
> If verify = "1" then WScript.Echo "vsinst85 = " & vsinst85 Else
> WScript.Echo "vsinst85 = " & vsinst85 End If
>
>
> If vsinst80 = False Then better than comparing to zero, but better to use: [if not vsinst80 then]
> GetMessage(1)
> End If
> If vsinst85 = False Then
> GetMessage(1)
> End If As you have written it, GetMessage(1) will be called once, twice, or zero
times, depending on how many of the two files being tested are found to
exist. If you want to call it once if either exists, here is one way:
if ( (not vsinst80) or (not vsinst85) ) then
GetMessage(1)
End If
I see no need here for a select statement, why is it that you want to use
one?
/Al