×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Checking network drive "heartbeat"?

Checking network drive "heartbeat"?

Checking network drive "heartbeat"?

(OP)
This may be a forehead slapper, but I've got to ask it anyway because I'm stumped...

I need a way to check if a network drive is still available that doens't hang my program up for over a minute if the network went down sometime after the program is ran.

Here's what's happening. I have a program that communicates with files/folders on a network drive. ON startup, the program checks to see if the network drive is visible. If it is, it continues on its merry way. However, if after the program is running, the network goes down, my program hangs for a little over a minute before it reports that the network drive is no longer available. As in (Not Responding) hangs :(

The routine I currently have in place to confirm the network drive availability looks something like this:

CODE --> VB6

Set FSO = CreateObject("SCRIPTING.FILESYSTEMOBJECT")

'CHECK "HEARTBEAT"
DE = FSO.DRIVEEXISTS(MAIN.DRIVELETTER.Caption) 'The network drive letter
If DE = False Then CHECKNETDRIVE = False: Exit Function 

As I said, if the network is up the the drive is visible when the program starts, no worries. But if it goes down, it's hanging me up pretty bad, and I'm at a loss on what to do.

Sorry if this is a noob question... self-taught programmers, OLD ones at that, sometimes need extra care and feeding

------------------------------------
yinyang Over 20 years of programming, and still learning every day! yinyang

RE: Checking network drive "heartbeat"?

(OP)

CODE -->

Public Function IsReachable(strComputer As String) As Boolean ' strComputer can be name or IP address
    Dim objWMIService As Object
    Dim objPing As Object
    Dim objStatus As Variant
    
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
    Set objPing = objWMIService.ExecQuery("Select * From Win32_PingStatus Where Address = '" & strComputer & "' and StatusCode=0")
    
    For Each objStatus In objPing
        IsReachable = objStatus.StatusCode = 0
    Next
End Function 

I feel like this might be what I'm looking for, but I'm not familiar with the WMI service... is there a way to modify this code to look by drive letter, rather than computer name?

------------------------------------
yinyang Over 20 years of programming, and still learning every day! yinyang

RE: Checking network drive "heartbeat"?

(OP)
Well DRAT... figured out a workaround to checking by drive letter (just go the sharename of the drive and parsed out the source computer name), but STILL getting a very long timeout/program hang.

The WMI check DID work just as it should... just not the result I was looking for. Thanks for the effort HughLerwill :)

------------------------------------
yinyang Over 20 years of programming, and still learning every day! yinyang

RE: Checking network drive "heartbeat"?

> just not the result I was looking for

Well, it was written as a fast ping function, which means what is does quickly check if you have basic network connectivity to the computer in question. But no, it was never intended to verify if a specific folder was accessible.

RE: Checking network drive "heartbeat"?

(OP)
And that was my intention... just to see if the drive was still connected/accessible. I know how to verify if files/folders exist or not ;)

------------------------------------
yinyang Over 20 years of programming, and still learning every day! yinyang

RE: Checking network drive "heartbeat"?

Sorry, should have been more explicit: it was never intended to verify if a specific folder or drive was accessible

RE: Checking network drive "heartbeat"?

IcmpSendEcho in Icmp.dll is more reliable in an application. It does not require that the heavyweight WMI Service be installed, running, and unsecured against standard user access.

RE: Checking network drive "heartbeat"?

(OP)
IcmpSendEcho... Hmmm... would you mind giving some sample code on how I could check a connection with a network computer named "mynetworkservercomputer" on the network? Pretty please??

------------------------------------
yinyang Over 20 years of programming, and still learning every day! yinyang

RE: Checking network drive "heartbeat"?

let's be clear here, if IsReachable does not do what you need then neither will icmpsendecho since IsReachable works by sending the same ping (albeit via WMI rather than a direct API) as icmpsendecho

>would you mind giving some sample code

If you do decide to proceed, then a quick search in this very forum against icmpsendecho will provide several code examples.

RE: Checking network drive "heartbeat"?

(OP)
Ok, I'll research it some.. thanks :)

------------------------------------
yinyang Over 20 years of programming, and still learning every day! yinyang

RE: Checking network drive "heartbeat"?

I agree that a ping only tells you that the server is running and reachable via a ping. It was really designed as a network connectivity test and nothing more.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close