Computing.Net > Forums > Programming > Ping script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Ping script

Reply to Message Icon

Name: SkyDomain
Date: July 16, 2003 at 17:16:35 Pacific
OS: Windows 2000 Pro
CPU/Ram: 850Mhz/256MB RAM
Comment:

I'm trying to write a script with visual basic and wan't to use the dos command:
"Ping (Server) -t"
How do i make this command launch when I press a button?



Sponsored Link
Ads by Google

Response Number 1
Name: Michael Ocana
Date: July 17, 2003 at 01:42:52 Pacific
Reply:

hi,

What do you want to use in scripting?
it depend on the script.

michael


0

Response Number 2
Name: Infinite Recursion
Date: July 17, 2003 at 16:05:04 Pacific
Reply:

SkyDomain:

Have a textbox labeled txtCommand.
Have a buttom labeled Command1.

Private Sub Command1_Click()
Shell (txtCommand.Text)
End Sub

What ever you type in the txtCommand
box will be executed by the shell if
applicable. For instance: "ping cnn.com"
without the double qoutes will result in the shell pinging cnn.com.

Hope this helps.

Infinite Recursion



0

Response Number 3
Name: SkyDomain
Date: July 18, 2003 at 18:42:13 Pacific
Reply:

Thanks Infinite Recursion it woked just great.
My next problem is how can I make a button that terminates the CMD window that opens?


0

Response Number 4
Name: Infinite Recursion
Date: July 19, 2003 at 15:11:06 Pacific
Reply:

SkyDomain:

Type the title of the window in the textbox and clicking the button will close the window. I suggest "hardcoding" the window name into a string and removing the text box, if the window title doesn't change
often.

Infinite Recursion

---------

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CLOSE = &H10

Private Sub Form_Load()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" & vbNewLine & "Note: must be an exact match")
If Ret = "" Then Exit Sub
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&

End Sub


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


MySQL Data Conversion perl drop down menu Oracl...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Ping script

Simple ping script in VB5 www.computing.net/answers/programming/simple-ping-script-in-vb5/17207.html

Ping Script www.computing.net/answers/programming/ping-script/15062.html

windows script www.computing.net/answers/programming/windows-script/18038.html