Solved

Expected Loop error

Posted on 2009-05-06
2
228 Views
Last Modified: 2012-05-06
Hi guys,
Ive been trying to work out what is wrong with the following code.
Im getting the following error:

Expected 'Loop'

Any help greatly appreciated.
<head>

<title>Enumerate System Information on Remote Computers</title>

<HTA:APPLICATION 

     APPLICATIONNAME="Enumerate System Information"

     SCROLL="yes"

     SINGLEINSTANCE="yes"

     WINDOWSTATE="normal"

>

<style type="text/css">

 

html {

font-family:arial;

font-size:smaller;

 

}

 

table {

border-collapse:collapse;

border:solid 1px black;

font-family:arial;

font-size:0.8em;

}

 

tr, td, th {

border-collapse:collapse;

border-style:solid;

}

 

td { border-width: 1px; }

 

 

</style>

 

 

</head>

<script language="vbscript">

Sub Window_onLoad

        intWidth = 600

        intHeight = 480

        Me.ResizeTo intWidth, intHeight

    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))

End Sub

 

Sub GetInfo

        run_button.disabled = True

        ComputerListFile.disabled = True

        Const ForReading = 1

        Const ForWriting = 2

        Set objFSO = CreateObject("Scripting.FileSystemObject")

 

        If ComputerListFile.Value <> "" Then

                If objFSO.FileExists(ComputerListFile.Value) = True Then

                        Set List = objFSO.OpenTextFile(ComputerListFile.Value, ForReading)

                        

                        strHTML = "<table width='40%' border=1 bgcolor='white'>" &_

                        "<th style='background:c0c0c0'><b>System</b></th><th style='background:c0c0c0'><b>Service Pack</b>"

                        Results.InnerHTML = strHTML

 			strHTML2 = "<table width='40%' border=1>" &_

                        "<th colspan='2' style='background:c0c0c0'><b>Number of Servers with:</b>"

			Totals.InnerHTML = strHTML2

			iArch1 = 0

			iArch2 = 0

			iArch3 = 0

			iArch4 = 0

			iArch5 = 0

			iArchU = 0

			iUnreach = 0

                        Do Until List.AtEndOfStream

                                strComputer = List.ReadLine

                                If Ping(strComputer) Then

 

                                        Set objWMIService = GetObject("winmgmts:" _

                                        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

                				    Set colProcessors = objWMIService.ExecQuery _

                				    ("Select * From Win32_Processor")
 

                                        For Each objProcessor in colProcessors

							strArch = "Arch Unknown"

							If objProcessor.Architecture = 0 Then strArch = "x86"

							If objProcessor.Architecture = 1 Then strArch = "MIPS"

							If objProcessor.Architecture = 2 Then strArch = "Alpha"

							If objProcessor.Architecture = 3 Then strArch = "PowerPC"

							If objProcessor.Architecture = 9 Then strArch = "x64"

                                        Next

 

                                        strHTML =  strHTML &"<tr><td width='40%' border=1>" & strComputer &_

                                        	"</td><td bgcolor='green'><font color='white'>" &strArch & "</font><br>"

                                	

							If strArch = "x86" then iArch1=iArch1+1

								Elseif strArch = "MIPS" then iArch2=iArch2+1

								Elseif strArch = "Alpha" then iArch3=iArch3+1

								Elseif strArch = "PowerPC" then iArch4=iArch4+1

								Elseif strArch = "x64" then iArch5=iArch5+1

							Else

								iArchU=iArchU+1

							End If
 

                                Else

							iUnreach = iUnreach + 1

                                        	strHTML =  strHTML &"<tr><td width='40%'>"& strComputer & "</td><td bgcolor='red'><font color='white'>Unreachable</font></td></tr><br>"

                                End If

                        Loop

			strHTML2 =  strHTML2 &"<tr><td width='80%' border=1>x86"&_

                         	"</td><td>" &iArch1 & "<br>"&_

				"<tr><td width='80%' border=1>MIPS"&_

                         	"</td><td>" &iArch2 & "<br>"&_

				"<tr><td width='80%' border=1>Alpha"&_

                         	"</td><td>" &iArch3 & "<br>"&_

				"<tr><td width='80%' border=1>PowerPC"&_

                         	"</td><td>" &iArch4 & "<br>"&_

				"<tr><td width='80%' border=1>x64"&_

                         	"</td><td>" &iArch5 & "<br>"&_

				"<tr><td width='80%' border=1>Unknown"&_

                         	"</td><td>" &iArchU & "<br>"&_

				"<tr><td width='80%' border=1>Unreachable"&_

                         	"</td><td>" &iUnreach & "<br>"&_

                        List.Close      

                        Totals.InnerHTML = strHTML2 &"</table>"

                        Results.InnerHTML =  strHTML &"</table>"

                Else

                        MsgBox "File does not exist: " & ComputerListFile.Value

                End If

        Else

                MsgBox "Please specify a file name."

        End If

        run_button.disabled = False

        ComputerListFile.disabled = False

 

End Sub

        

Function Ping(strComputer)

        Dim objShell, boolCode

        Set objShell = CreateObject("WScript.Shell")

        boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)

        If boolCode = 0 Then

                Ping = True

        Else

                Ping = False

        End If

End Function

 

</script>

 

<body>

<input type="button" value="Run Script" name="run_button" onClick="GetInfo">

<input type="file" name="ComputerListFile"> <br><br>

<span id = "Totals"></span><br><br>

<span id = "Results"></span>

</body>

</html>

Open in new window

0
Comment
Question by:Simon336697
2 Comments
 
LVL 10

Accepted Solution

by:
TakedaT earned 500 total points
ID: 24322913
Here you go Simon.  Your IF statement from line 89 to 96 was syntaxed wrong.  When you continue an If statement after the "then" on the same line, that terminates the statement.  The elseif's had the same problem.  All I did was add the carriage returns after the thens.

I also changed the title of the second column to "Processor type" instead of "Service Pack" as it looks like you changed what you wanted it to display.
<head>

<title>Enumerate System Information on Remote Computers</title>

<HTA:APPLICATION 

     APPLICATIONNAME="Enumerate System Information"

     SCROLL="yes"

     SINGLEINSTANCE="yes"

     WINDOWSTATE="normal"

>

<style type="text/css">

 

html {

font-family:arial;

font-size:smaller;

 

}

 

table {

border-collapse:collapse;

border:solid 1px black;

font-family:arial;

font-size:0.8em;

}

 

tr, td, th {

border-collapse:collapse;

border-style:solid;

}

 

td { border-width: 1px; }

 

 

</style>

 

 

</head>

<script language="vbscript">

Sub Window_onLoad

	intWidth = 600

	intHeight = 480

	Me.ResizeTo intWidth, intHeight

	Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))

End Sub

 

Sub GetInfo

        run_button.disabled = True

        ComputerListFile.disabled = True

        Const ForReading = 1

        Const ForWriting = 2

        Set objFSO = CreateObject("Scripting.FileSystemObject")

 

        If ComputerListFile.Value <> "" Then

                If objFSO.FileExists(ComputerListFile.Value) = True Then

                        Set List = objFSO.OpenTextFile(ComputerListFile.Value, ForReading)

                        

                        strHTML = "<table width='40%' border=1 bgcolor='white'>" &_

                        "<th style='background:c0c0c0'><b>System</b></th><th style='background:c0c0c0'><b>Processor Type</b>"

                        Results.InnerHTML = strHTML

 			strHTML2 = "<table width='40%' border=1>" &_

                        "<th colspan='2' style='background:c0c0c0'><b>Number of Servers with:</b>"

			Totals.InnerHTML = strHTML2
 

			iArch1 = 0

			iArch2 = 0

			iArch3 = 0

			iArch4 = 0

			iArch5 = 0

			iArchU = 0

			iUnreach = 0

                        Do Until List.AtEndOfStream

                                strComputer = List.ReadLine

                                If Ping(strComputer) Then

                                        Set objWMIService = GetObject("winmgmts:" _

                                        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

                				    Set colProcessors = objWMIService.ExecQuery _

                				    ("Select * From Win32_Processor")

                                        For Each objProcessor in colProcessors

							strArch = "Arch Unknown"

							If objProcessor.Architecture = 0 Then strArch = "x86"

							If objProcessor.Architecture = 1 Then strArch = "MIPS"

							If objProcessor.Architecture = 2 Then strArch = "Alpha"

							If objProcessor.Architecture = 3 Then strArch = "PowerPC"

							If objProcessor.Architecture = 9 Then strArch = "x64"

                                        Next

                                        strHTML =  strHTML &"<tr><td width='40%' border=1>" & strComputer &_

                                        	"</td><td bgcolor='green'><font color='white'>" &strArch & "</font><br>"

					If strArch = "x86" then

						iArch1=iArch1+1

					Elseif strArch = "MIPS" then

						iArch2=iArch2+1

					Elseif strArch = "Alpha" then

						iArch3=iArch3+1

					Elseif strArch = "PowerPC" then

						iArch4=iArch4+1

					Elseif strArch = "x64" then

						iArch5=iArch5+1

					Else

						iArchU=iArchU+1

					End If

                                Else

					iUnreach = iUnreach + 1

                                        strHTML =  strHTML &"<tr><td width='40%'>"& strComputer & "</td><td bgcolor='red'><font color='white'>Unreachable</font></td></tr><br>"

                                End If

                        Loop

			strHTML2 =  strHTML2 &"<tr><td width='80%' border=1>x86"&_

                         	"</td><td>" &iArch1 & "<br>"&_

				"<tr><td width='80%' border=1>MIPS"&_

                         	"</td><td>" &iArch2 & "<br>"&_

				"<tr><td width='80%' border=1>Alpha"&_

                         	"</td><td>" &iArch3 & "<br>"&_

				"<tr><td width='80%' border=1>PowerPC"&_

                         	"</td><td>" &iArch4 & "<br>"&_

				"<tr><td width='80%' border=1>x64"&_

                         	"</td><td>" &iArch5 & "<br>"&_

				"<tr><td width='80%' border=1>Unknown"&_

                         	"</td><td>" &iArchU & "<br>"&_

				"<tr><td width='80%' border=1>Unreachable"&_

                         	"</td><td>" &iUnreach & "<br>"&_

                        List.Close      

                        Totals.InnerHTML = strHTML2 &"</table>"

                        Results.InnerHTML =  strHTML &"</table>"

                Else

                        MsgBox "File does not exist: " & ComputerListFile.Value

                End If

        Else

                MsgBox "Please specify a file name."

        End If

        run_button.disabled = False

        ComputerListFile.disabled = False

 

End Sub

        

Function Ping(strComputer)

        Dim objShell, boolCode

        Set objShell = CreateObject("WScript.Shell")

        boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)

        If boolCode = 0 Then

                Ping = True

        Else

                Ping = False

        End If

End Function

 

</script>

 

<body>

<input type="button" value="Run Script" name="run_button" onClick="GetInfo">

<input type="file" name="ComputerListFile"> <br><br>

<span id = "Totals"></span><br><br>

<span id = "Results"></span>

</body>

</html>

Open in new window

0
 
LVL 1

Author Comment

by:Simon336697
ID: 24323009
Takeda,

I dont know how you do it, but you do, and you do it incredibly well.
Thank you again mate.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now