Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File version and exist issue loop

Status
Not open for further replies.

Junbron

Technical User
Mar 5, 2012
15
NZ
I have this scrpit below...
but getting error saying
Line 40 Code 800A03EA


and i added in the original script are

Else

if objFSO.FileExists("C:\orant\BIN\GLAHE11I.EXE") then
do while not oFile.atendofstream
strPCNum=oFile.readline
if Ping(strPCNum) = False Then
strOutText = strRemoteFile + vbTab + "Not installed"
oFile2.WriteLine(strOutText)


because i getting error on my orignal script withoout above code when a machine is on and doesnt have the file

================================================
dim objFSO, strFile, strFilePath, OFile, oFile2, strPCNum, strOutputFile, strRemoteFile, strFileVersion, strOutText
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("WScript.Shell")

strFilePath = "C:\orant\BIN\GLAHE11I.EXE"
strInputFile = "C:\Documents and Settings\!cachoe\Desktop\adi\List.csv"
strOutputFile = "C:\Documents and Settings\!cachoe\Desktop\adi\Version.txt"

if objFSO.FileExists(strInputFile) then
set oFile=objFSO.OpenTextFile(strInputFile,1)
set oFile2=objFSO.OpenTextFile(strOutputFile,8,True)
do while not oFile.atendofstream
strPCNum=oFile.readline
if Ping(strPCNum) = False Then
strOutText = strRemoteFile + vbTab + "Off LINe"
oFile2.WriteLine(strOutText)
Else

if objFSO.FileExists("C:\orant\BIN\GLAHE11I.EXE") then
do while not oFile.atendofstream
strPCNum=oFile.readline
if Ping(strPCNum) = False Then
strOutText = strRemoteFile + vbTab + "Not installed"
oFile2.WriteLine(strOutText)

Else
arrayFile = split(strFilePath, ":")
strRemoteFile = "\\" + strPCNum + "\" + arrayFile(0) + "$" + arrayFile(1)
strFileVersion = objFSO.GetFileVersion(strRemoteFile)
strOutText = strRemoteFile + vbTab + strFileVersion
oFile2.WriteLine(strOutText)
end if
loop
else
wscript.echo "File containing list of PCs does not exist. Quitting Program"
wscript.quit
oFile.close
oFile2.Close
end if
Function Ping(PC)
Set objWshScriptExec = objShell.Exec("ping.exe -n 1 " & PC)
Set objStdOut = objWshScriptExec.StdOut

awake=False
Do Until objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
awake = awake Or InStr(LCase(strLine), "bytes=") > 0
Loop
Ping = awake

End Function

WScript.Echo "Done"

 
What is the text of the error? Where does your code actually start? Can't tell where line 40 is so can you repost your and surround it with [ignore]
Code:
[/ignore] tags to preserve formatting. At first glance, I count 6 [green]"openers"[/green] and only 3 [red]"closers"[/red]. Where' the rest of the code?

Code:
[green]if objFSO.FileExists(strInputFile) then[/green]
	set oFile=objFSO.OpenTextFile(strInputFile,1)
	set oFile2=objFSO.OpenTextFile(strOutputFile,8,True)
	[green]do while not oFile.atendofstream[/green]
		strPCNum=oFile.readline 
		[green]if Ping(strPCNum) = False Then[/green]
			strOutText = strRemoteFile + vbTab + "Off LINe"
			oFile2.WriteLine(strOutText)
		Else
			[green]if objFSO.FileExists("C:\orant\BIN\GLAHE11I.EXE") then[/green]
				[green]do while not oFile.atendofstream[/green]
					strPCNum=oFile.readline 
					[green]if Ping(strPCNum) = False Then[/green]
						strOutText = strRemoteFile + vbTab + "Not installed"
						oFile2.WriteLine(strOutText)
					Else
						arrayFile = split(strFilePath, ":")
						strRemoteFile = "\\" + strPCNum + "\" + arrayFile(0) + "$" + arrayFile(1)
						strFileVersion = objFSO.GetFileVersion(strRemoteFile)
						strOutText = strRemoteFile + vbTab + strFileVersion
						oFile2.WriteLine(strOutText)
					[red]end if[/red]
				[red]loop[/red]
			else
				wscript.echo "File containing list of PCs does not exist. Quitting Program"
				wscript.quit
				oFile.close
				oFile2.Close
			[red]end if[/red]

-Geates


"I do not offer answers, only considerations."
- Geates's Disclaimer

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top