Solved

Expected Loop error

Posted on 2009-05-06
2
225 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
Comment Utility
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
Comment Utility
Takeda,

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

10 Experts available now in Live!

Get 1:1 Help Now