I'd like to make my CLI file copy utils do something like "if target is a disconnect network drive, wake it up first".
The answer seems to rely somewhere in the functions RealDriveType, IsNetDrive, and WNetRestoreConnection.
These are functions that the DOJ forced MS to expose and the documentation is total balls. This page has better info than MSDN :
http://vbnet.mvps.org/index.html?code/network/isnetdrive.htm
I'm seeing some weird things with them though. For one thing, IsNetDrive is not a light query. It actually stalls and tries to wake up the drive right there, so most of the time all you have to do is call IsNetDrive and that actually will restore the connection. IsNetDrive can stall out for a very long time.
IsNetDrive also lies, as that page I linked details.
I haven't gotten WNetRestoreConnection to do anything useful. It always tells me "The local device name is already in use".
WNetRestoreConnection also pops up an interactive dialog box when it has errors which is fucking evil.
So ... in every case I've tried so far IsNetDrive actually refreshes the connection. I haven't yet found a need to actually call WNetRestoreConnection, which is good because it doesn't seem to work.
I would start with the "net" command. Type "net help" at the command line, maybe "net help shared".
ReplyDeleteSeriously?
ReplyDelete...
Anyhoo, the answer seems to rely somewhere in the functions RealDriveType, IsNetDrive, and WNetRestoreConnection.
These are functions that the DOJ forced MS to expose and the documentation is total balls. This page has better info than MSDN :
http://vbnet.mvps.org/index.html?code/network/isnetdrive.htm
I'm seeing some weird things with them though. For one thing, IsNetDrive is not a light query. It actually stalls and tries to wake up the drive right there, so most of the time all you have to do is call IsNetDrive and that actually will restore the connection. IsNetDrive can stall out for a very long time.
IsNetDrive also lies, as that page I linked details.
I haven't gotten WNetRestoreConnection to do anything useful. It always tells me "The local device name is already in use".
WNetRestoreConnection also pops up an interactive dialog box when it has errors which is fucking evil.