tags:

views:

20

answers:

1

I'm calling WNetAddConnection2 during the login process for a 2008R2 box. The action happens right after userinit is run. I'm receiving a 1222 error or Network Not Available. Right after doing this I'm also connecting a couple printers using the AddPrinterConnection function. Both the printers and the network drives are on the same remote machine.

Why do the printer connections work but the network drive connections fail?

+1  A: 

Could be a timing issue (network startup still in progress while first call is made). Have you tried reversing the order of the calls?

It's also possible that AddPrinterConnection (which blocks) waits for resources to be available whereas the other does not. have you tried connecting all resources using WNetAddConnection2? Maybe that would fail your your printers too.

Can you make all of this processing dependent on verification of network status via Network Location Awareness?

Steve Townsend
I was looking everywhere for something like that NLA. Thanks! It seems that WNetAddConnection2 caches connection info or something because when I launch a new process instead of waiting in the first process (I tried to wait for like 15 seconds to see if that would change anything) I can successfully map the drives.
Adam Driscoll