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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hta:passing value from input to a ping funtion

Status
Not open for further replies.

brlissab

Technical User
Oct 11, 2002
35
0
0
CH
Hello there everyone.
Having some problems to pass value to a function.
Take Microsoft sample to let choose user's a text file with computer names and then execute actions on these machines, on my sample a ping function.
here is my code
Code:
<html>
<head>
<title>Load Computers Sample</title>
<HTA:APPLICATION 
     ID="objTestHTA"
     APPLICATIONNAME="Load Computers Sample"
     SCROLL="No"
     SINGLEINSTANCE="yes"
     BORDER="thick"
     CAPTION="No"
>
</head>

<SCRIPT Language="VBScript">

Sub ExitApp
		self.Close()
        End Sub

Sub Window_OnLoad()
          'Set Window Size and Location
  
          Window.ResizeTo 550, 600
          Window.moveTo (screen.width-100)/2, (screen.height-500)/2
      End Sub

Sub LoadComputers

    Set objDialog = CreateObject("UserAccounts.CommonDialog")
    objDialog.Filter = "Text Files|*.txt|All Files|*.*"
    objDialog.FilterIndex = 1
    objDialog.InitialDir = "C:\Scripts"
    intResult = objDialog.ShowOpen

    If intResult = 0 Then
        Exit Sub
    End If

    For Each objOption in AvailableComputers.Options
        objOption.RemoveNode
    Next
    
    ForReading = 1
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile _
        (objDialog.FileName, ForReading)
    Do Until objFile.AtEndOfStream
        strLine = objFile.ReadLine
        Set objOption = Document.createElement("OPTION")
        objOption.Text = strLine
        objOption.Value = strLine
 strComputer=AvailableComputers.Add(objOption)		
   Loop
    objFile.Close

End Sub

Sub Main
if PingHost(strcomputer) Then
	MsgBox "onLine"
Else
	MsgBox "offLine"
End IF
End Sub

Function PingHost(cp)

Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & cp)
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
  PingHost = True
Else
  PingHost = False
End If

End Function



Sub ExitApp
		self.Close()
        End Sub

</SCRIPT>

<body bgcolor="buttonface">
<input id=runbutton  class="button" type="button" value="Charger liste ordinateurs" 
name="run_button"  onClick="LoadComputers"><p>

<select size="25" name="AvailableComputers" style="width:500" >
</select>
<p>
<input type="button" value="Quitter" name="Quitter" onClick="ExitApp">
<input type="button" value="Run" name="Run" onclick="Main">
<p>
<span id= "DataArea"></span>

</body>
</html>

still working, but fails on result(just try it on localhost) and result always offline.
Eventually, could you folks give me a link where i could have more info about it.
Best regards
Bruno
 
tried this multibox for choice one or more machines

Code:
Sub RunScript
    For i = 0 to (MultiListbox.Options.Length - 1)
        If (MultilistBox.Options(i).Selected) Then
            strComputer = strComputer & MultilistBox.Options(i).Value & vbcrlf
        End If
    Next
    PingHost strComputer
End Sub




Sub PingHost(cp)

Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & cp)
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
  MsgBox  CP & " IS Online"
Else
  MsgBox  CP & " IS OffLine"
End If

End Sub


</SCRIPT>

<body>

<select size="3" name="MultilistBox" multiple>
    [COLOR=red]<option value="PRATINTERNET1">PRATINTERNET1</option>[/color]
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>
</select>
<p>
<input id=runbutton  type="button" value="Run" name="run_button"  onClick="RunScript">
<input id=closeButton type="button" value="Close" name="Close_button" onClick="Closeapp">
</body>

want to pass choissed value to another function, so i change the option value into the "real value" that i wanna pass into another sub another actions and so on, but im not there...
is it possible? eventualy if you folks known for ressources, didn't find something yet on technet.
best regards
bruno


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top