Network Drive Connection Errors - A Way to Check Before the Fact?

K

krwinter

I'm having a repeatable problem that occurs when I programmatically try
and access a network drive that's mapped, but physically absent. If
the machine that the drive exists on is physically taken offline
(reboot or taken off the nwtwork), any attempt to programatically
access that drive results in an unrecoverable error - get the typical
popup message "An error occurred while reconnecting... device name
already in use... connection has not been restored." What's worse is
even when the machine that contains the physical drive comes back, the
network drive is permanently inaccessible, and I reboot to restore
(though there may be a better way, reboot always does the trick).

Specifically, I have a vbs program that checks a folder on the network
drive every second looking for new files. This has run fine for months
uninterrupted. But if the machine that contains the network drive is
rebooted while my monitoring program is running, train wreck. All this
program tries to do is look at a folder on K:\MyFolder, and does not
fail gracefully, quite the opposite. I get the same train wreck if a
completely different program, running as a service, does the same thing
and tries to access the network drive when it's physically not there.

My question, are there any settings I can tweak to make this fail
gracefully and NOT lock up? I'm guessing that's WAY too much to hope
for.

So, any way before the fact to check that the network drive is there?
I've tried the wscript "WScript.Network" method "EnumNetworkDrives" and
all this shows me is yes, the drive is mapped, but not whether it's
physically there or not.

I HAVE tried "net use K:", and get back OK or DISCONNECTED, but OK to
run this every second for months and months?

Any other suggestions?

Thanks!

Ken
 
F

Frankster

Well, you're the programmer, :), but if you can implement the following
into your program it should work. This is a simple command line method often
used in scripts/batchfiles.

U:\>if exist x:\pagefile.sys echo yes
yes

or...

U:\>if exist x:\pagefile.sys DOSOMETHING
DOSOMETHING

-Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top