Click here to Skip to main content
15,915,791 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Calling a button click Pin
Jim Matthews15-Mar-05 10:32
Jim Matthews15-Mar-05 10:32 
GeneralLoop Question Pin
Makniteasy15-Mar-05 7:27
Makniteasy15-Mar-05 7:27 
GeneralRe: Loop Question Pin
Jim Matthews15-Mar-05 8:30
Jim Matthews15-Mar-05 8:30 
GeneralRe: Loop Question Pin
Makniteasy15-Mar-05 8:42
Makniteasy15-Mar-05 8:42 
GeneralRe: Loop Question Pin
Jim Matthews15-Mar-05 9:09
Jim Matthews15-Mar-05 9:09 
GeneralRe: Loop Question Pin
Dave Kreskowiak15-Mar-05 9:11
mveDave Kreskowiak15-Mar-05 9:11 
GeneralRe: Loop Question Pin
Makniteasy17-Mar-05 7:15
Makniteasy17-Mar-05 7:15 
GeneralHTA and IsConnectible Ping Pin
pn199515-Mar-05 3:32
pn199515-Mar-05 3:32 
I'm having another issue with my little HTA application that I'm hoping you could advise on.

Basically when a user enters a PC name in a box and selects GO. I want the code to run a ping against the remote machine to see if it is online or not. Now in a normal vb script the IsConnectible ping check works great. However when called from within my HTA app it always come back and says that the PC is online.

Anyone know why its not working in the HTA?

This is my code...thanks



<title>System Information
<hta:application
="" id="objSysInfo" applicationname="System Information" scroll="yes" singleinstance="yes" windowstate="maximize">






Sub MainSub
On Error Resume Next



DataArea.InnerHTML= " "
sComputer = ComputerTextBox.Value
If sComputer = Empty Then
strHTML = strHTML & "Please Enter a Computer Name "
DataArea.InnerHTML = strHTML

Else
If IsConnectible(sComputer,"","") Then
strHTML = strHTML & "Computer is online"
Else
strHTML = strHTML & "Computer is offline"

End If
DataArea.InnerHTML = strHTML
End If

End Sub

Sub IsConnectible(sHost, iPings, iTO)
' Returns True or False based on the output from ping.exe
'
' Author: Alex Angelopoulos/Torgeir Bakken
' Works an "all" WSH versions
' sHost is a hostname or IP

' iPings is number of ping attempts
' iTO is timeout in milliseconds
' if values are set to "", then defaults below used

If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750

Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = sTemp & "\runresult.tmp"

oShell.Run "%comspec% /c ping -n " & iPings & " -w " & iTO _
& " " & sHost & ">" & sTempFile, 0 , True

Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
FailIfNotExist, OpenAsDefault)

sResults = fFile.ReadAll
fFile.Close
oFSO.DeleteFile(sTempFile)
IsConnectible = CBool(InStr(sResults, "TTL="))

End Sub






 























 


 









GeneralRe: HTA and IsConnectible Ping Pin
Dave Kreskowiak15-Mar-05 6:22
mveDave Kreskowiak15-Mar-05 6:22 
Generalneed help: deserialise Pin
Dahoolio15-Mar-05 3:14
Dahoolio15-Mar-05 3:14 
GeneralRe: need help: deserialise Pin
Dave Kreskowiak15-Mar-05 6:17
mveDave Kreskowiak15-Mar-05 6:17 
GeneralRe: need help: deserialise Pin
Dahoolio16-Mar-05 20:17
Dahoolio16-Mar-05 20:17 
GeneralRe: need help: deserialise Pin
Dahoolio15-Mar-05 20:40
Dahoolio15-Mar-05 20:40 
QuestionHOW TO: populate Menus at runtime Pin
azam31614-Mar-05 19:39
azam31614-Mar-05 19:39 
AnswerRe: HOW TO: populate Menus at runtime Pin
rwestgraham14-Mar-05 21:38
rwestgraham14-Mar-05 21:38 
GeneralHide Tabpage Pin
Mohamed Ishak14-Mar-05 19:27
professionalMohamed Ishak14-Mar-05 19:27 
GeneralRe: Hide Tabpage Pin
rwestgraham14-Mar-05 21:04
rwestgraham14-Mar-05 21:04 
GeneralRe: Hide Tabpage Pin
Mohamed Ishak15-Mar-05 2:59
professionalMohamed Ishak15-Mar-05 2:59 
GeneralDetecting CD drive media change Pin
thebox211214-Mar-05 17:16
thebox211214-Mar-05 17:16 
GeneralRe: Detecting CD drive media change Pin
thebox211214-Mar-05 17:52
thebox211214-Mar-05 17:52 
GeneralRe: Detecting CD drive media change Pin
Dr_Lomax16-Mar-05 14:38
Dr_Lomax16-Mar-05 14:38 
GeneralRe: Detecting CD drive media change Pin
Dr_Lomax16-Mar-05 14:42
Dr_Lomax16-Mar-05 14:42 
GeneralVB and Matlab Pin
Anonymous14-Mar-05 17:10
Anonymous14-Mar-05 17:10 
QuestionValidating ? Pin
Progzz14-Mar-05 16:16
Progzz14-Mar-05 16:16 
AnswerRe: Validating ? Pin
Christian Graus14-Mar-05 16:45
protectorChristian Graus14-Mar-05 16:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.