Sign in to follow this  
Followers 0
LondonNDIB

DriveStatus() with network drives

8 posts in this topic

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

Share this post


Link to post
Share on other sites



Not tested but might work

$t = Run("explorer.exe C:\", "", @SW_HIDE)

WinClose($t)


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

Share this post


Link to post
Share on other sites

Wow, that was fast!

Thanks, I'll test that right now and report.

- LD

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Look in the helpfile for ProcessClose / kill cant remember it


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

Share this post


Link to post
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...

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0