I am having a problem with a statements:

Const HKEY_LOCAL_MACHINE = &H80000002
Const ForReading = 1
Dim shell
Set shell = CreateObject("WScript.shell")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("U:\Scripts\EPO\Inputfile.txt",
ForReading)
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
Path = ("\\"& strComputer & "\C$\Program Files\Network Associates\Common
Framework\FrameworkService.exe")
Path1 = ("\\"& strComputer & "\c$\program files\McAfee\Common
Framework\FrameworkService.exe")

If path = "" Then
WScript.Echo strComputer & ":" & " EPO File Version is " &
objFSO.GetFileVersion (Path)
ElseIf path1 = "" Then
WScript.Echo strComputer & ":" & " EPO File Version is " &
objFSO.GetFileVersion (Path1)
Else
WScript.Echo strComputer & ":" & " EPO is not installed"
End If
Loop

objTextFile.Close

When I run the script on my machine it goes to the last line even if I have
a path on my machine. Maybe I am just confused

Re: if then statements by Pegasus

Pegasus
Mon Apr 28 11:33:20 CDT 2008


"freddy" <freddy@discussions.microsoft.com> wrote in message
news:1D484329-317B-4258-B5A3-2586E6DA5A9D@microsoft.com...
>I am having a problem with a statements:
>
> Const HKEY_LOCAL_MACHINE = &H80000002
> Const ForReading = 1
> Dim shell
> Set shell = CreateObject("WScript.shell")
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile("U:\Scripts\EPO\Inputfile.txt",
> ForReading)
> Do Until objTextFile.AtEndOfStream
> strComputer = objTextFile.Readline
> Path = ("\\"& strComputer & "\C$\Program Files\Network Associates\Common
> Framework\FrameworkService.exe")
> Path1 = ("\\"& strComputer & "\c$\program files\McAfee\Common
> Framework\FrameworkService.exe")
>
> If path = "" Then
> WScript.Echo strComputer & ":" & " EPO File Version is " &
> objFSO.GetFileVersion (Path)
> ElseIf path1 = "" Then
> WScript.Echo strComputer & ":" & " EPO File Version is " &
> objFSO.GetFileVersion (Path1)
> Else
> WScript.Echo strComputer & ":" & " EPO is not installed"
> End If
> Loop
>
> objTextFile.Close
>
> When I run the script on my machine it goes to the last line even if I
> have
> a path on my machine. Maybe I am just confused

The two lines of code
Path = ("\\"& strComputer & "\C$\Program Files\Network Associates\Common
Framework\FrameworkService.exe")
Path1 = ("\\"& strComputer & "\c$\program files\McAfee\Common
Framework\FrameworkService.exe")

will set Path and Path1 to something other than a null string,
regardless of the value of strComputer. The result you see
is entirely expected. Did you perhaps want to test for
strComputer?

Inserting some strategic statements like

wscript.echo "Path=" & Path

will reveal this type of oversight immediately.