Jump to content

DriveStatus() with network drives


Recommended Posts

I use DriveStatus to be sure a chosen drive actually exists and is ready to before performing the rest of the script (backup routine).

Thing is... it's not very predictable with mapped network drives.

I have a mapped drive x:, for example... that returns "NOTREADY" (or sometimes "INVALID") until I manually go and browse the drive in Explorer... then after that point, it returns as "READY".

How do you suppose I can ready the drive without having to manually browse it?

Thanks.

- LD

Link to comment
Share on other sites

It works... and its fine on my machine, but I wonder how universal it would be.

First off, there needs to be a delay introduced. For my setup, 1000ms seems to work fine.

MsgBox ( "", "", DriveStatus ( "z:" ) );should report INVALID or NOTREADY
$t = Run("explorer.exe z:\", "", @SW_HIDE)
sleep ( 1000 )
WinClose($t)
MsgBox ( "", "", DriveStatus ( "z:" ) );should report READY

My concerns:

1) is 1000ms right for everyone? Will network speed, cpu speed, etc affect this?

2) will this work on all versions of (AutoIt supported) Windows?

3) Is WinClose the best way of doing this, or could it be more (guranteed) reliable killing the process directly?

This is a great start, and may even be the end! It just seems like something that might need extensive testing, and I'm not keen on that for such a small part of this app :whistle:

I was hoping there would be a reliable and tested WakeNetworkDrive() or some such :)

Thanks again!

- LD

Link to comment
Share on other sites

MsgBox ( "", "", DriveStatus ( "z:" ) );should report INVALID or NOTREADY

$t = RunWait("explorer.exe z:\", "", @SW_HIDE)

WinClose($t)

MsgBox ( "", "", DriveStatus ( "z:" ) );should report READY

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Link to comment
Share on other sites

  • 1 month later...

I am trying to use autoit to check if a certain drive is mapped and change the mapping to another if it is or map the drive/share if not already mapped. Can Autoit check to see if the drive letter is mapped and then change it if it is and if not mapped go ahead and map it?

Thanks...

Link to comment
Share on other sites

I am trying to use autoit to check if a certain drive is mapped and change the mapping to another if it is or map the drive/share if not already mapped. Can Autoit check to see if the drive letter is mapped and then change it if it is and if not mapped go ahead and map it?

Thanks...

The functions for dealing with all different drive types are available natively w/ au3, see the Drive... funcs, with the exception of SUBST'ed paths.

It is certainly possible to ensure that drives are functional before use. To address the inconsistencies in the windows functions called by au3, I chose to write a wrapper around the "net use" commands and the sysinternals 'handle' command, as I could force any open handles closed such that I could guarantee that a given UNC path was mapped to a given drive letter.

Extremely useful for switching between production and development environments, for example.

Of course, all of this functionality is easily implemented in plain .cmd (batch files), as well.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...