Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista Tutorial - Calling a VBScript from Access

Reply
 
Old 06-22-2009   #1 (permalink)
DetRich
Guest


 
 

Calling a VBScript from Access

Hello,

I have an Access application from which I need to call a vbscript which will
ping a server and display results to the user.

In Access, a form displays a record. This record has the hostname of a
server. When clicking the "Ping Server" command button, the vbscript should
be called.

I need to know how to pass the hostname of the server to the ping command.
Can anyone help me understand how to pass this hostname to the script so that
the correct server is returned? The script can either interpret the results
and display a success or fail message or the results of the ping can be
written to a file and the script can read the file, then display the results.

TIA,
DetRich

My System SpecsSystem Spec
Old 06-22-2009   #2 (permalink)
Pegasus [MVP]
Guest


 
 

Re: Calling a VBScript from Access


"DetRich" <DetRich@xxxxxx> wrote in message
news:9B513BBF-7B27-4C9A-98CC-DCE228526A31@xxxxxx
Quote:

> Hello,
>
> I have an Access application from which I need to call a vbscript which
> will
> ping a server and display results to the user.
>
> In Access, a form displays a record. This record has the hostname of a
> server. When clicking the "Ping Server" command button, the vbscript
> should
> be called.
>
> I need to know how to pass the hostname of the server to the ping command.
> Can anyone help me understand how to pass this hostname to the script so
> that
> the correct server is returned? The script can either interpret the
> results
> and display a success or fail message or the results of the ping can be
> written to a file and the script can read the file, then display the
> results.
>
> TIA,
> DetRich
Why not call ping.exe directly from Access, then pick up the ErrorLevel:
cmd /c ping RichServer | find /i "bytes=" >nul


My System SpecsSystem Spec
Old 06-23-2009   #3 (permalink)
Jeff C
Guest


 
 

RE: Calling a VBScript from Access

"DetRich" wrote:
Quote:

> Hello,
>
> I have an Access application from which I need to call a vbscript which will
> ping a server and display results to the user.
>
> In Access, a form displays a record. This record has the hostname of a
> server. When clicking the "Ping Server" command button, the vbscript should
> be called.
The form is displaying the hostname in a textbox which you can reference in
your VB script ie: me.txtboxname

The "OnClick" event should have your VBscript copied into it refencing the
txtbox as above. In Access rather than using "SHELL" to run the *.vbs file
you can just use the content on the vbs file and with modest changes it
generally runs fine.
Quote:

>
> I need to know how to pass the hostname of the server to the ping command.
> Can anyone help me understand how to pass this hostname to the script so that
> the correct server is returned? The script can either interpret the results
> and display a success or fail message or the results of the ping can be
> written to a file and the script can read the file, then display the results.
>
> TIA,
> DetRich
My System SpecsSystem Spec
Old 07-01-2009   #4 (permalink)
Mark D. MacLachlan
Guest


 
 

Re: Calling a VBScript from Access

DetRich wrote:
Quote:

> Hello,
>
> I have an Access application from which I need to call a vbscript
> which will ping a server and display results to the user.
>
> In Access, a form displays a record. This record has the hostname of
> a server. When clicking the "Ping Server" command button, the
> vbscript should be called.
>
> I need to know how to pass the hostname of the server to the ping
> command. Can anyone help me understand how to pass this hostname to
> the script so that the correct server is returned? The script can
> either interpret the results and display a success or fail message or
> the results of the ping can be written to a file and the script can
> read the file, then display the results.
>
> TIA,
> DetRich
Rather than going the route you are, why not use the WMI PingStatus
class which will return a ping status for you? Here is a function that
does it.

Code:
Function PingStatus(strComputer)

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colPings = objWMIService.ExecQuery _
("SELECT * FROM Win32_PingStatus WHERE Address = '" & strComputer
& "'")
For Each objPing in colPings
Select Case objPing.StatusCode
Case 0 PingStatus = "Success"
Case 11001 PingStatus = "Status code 11001 - Buffer Too
Small"
Case 11002 PingStatus = "Status code 11002 - Destination
Net Unreachable"
Case 11003 PingStatus = "Status code 11003 - Destination
Host Unreachable"
Case 11004 PingStatus = _
"Status code 11004 - Destination Protocol Unreachable"
Case 11005 PingStatus = "Status code 11005 - Destination
Port Unreachable"
Case 11006 PingStatus = "Status code 11006 - No Resources"
Case 11007 PingStatus = "Status code 11007 - Bad Option"
Case 11008 PingStatus = "Status code 11008 - Hardware Error"
Case 11009 PingStatus = "Status code 11009 - Packet Too Big"
Case 11010 PingStatus = "Status code 11010 - Request Timed
Out"
Case 11011 PingStatus = "Status code 11011 - Bad Request"
Case 11012 PingStatus = "Status code 11012 - Bad Route"
Case 11013 PingStatus = "Status code 11013 - TimeToLive
Expired Transit"
Case 11014 PingStatus = _
"Status code 11014 - TimeToLive Expired Reassembly"
Case 11015 PingStatus = "Status code 11015 - Parameter
Problem"
Case 11016 PingStatus = "Status code 11016 - Source Quench"
Case 11017 PingStatus = "Status code 11017 - Option Too Big"
Case 11018 PingStatus = "Status code 11018 - Bad
Destination"
Case 11032 PingStatus = "Status code 11032 - Negotiating
IPSEC"
Case 11050 PingStatus = "Status code 11050 - General
Failure"
Case Else PingStatus = "Status code " & objPing.StatusCode
& _
" - Unable to determine cause of failure."
End Select
Next

End Function
Hope that helps.

Regards,

Mark D. MacLachlan

--

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Get access token information using vbscript ? VB Script
calling WinAPIs from VBScript VB Script
Access textbox contents to Word via VBScript VB Script
Calling Executable from VBScript VB Script
Vbscript calling DTS package VB Script


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46