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
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
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