Sorry this is a long Q...
I'm having problems trying to deal with two legacy apps that both have to use a drive mapping to the same drive letter but on different servers (don't ask!!). These applications have not needed to be on the same PCs until now. To make matters worse, the drive mappings are configured locally on the machine - either statically mapped in the user's profile or by a NET USE batch file in the All Users' Startup folder.
To try and make them coexist I've written two chunks of VBScript (one for each app) to act as the user's launch points for them. These work by disconnecting the existing drive if it's the wrong one and then creating the new mapping and launching the app.
This works a treat on a new PC but on a PC where the user profile already contained a drive mapping it runs into problems:
In this case, on logging in, the drive letter shows up in Explorer as a Disconnected Drive and crucially, is invisible to the Win32_LogicalDisk WMI class that I was using to check for an existing drive mapping - that means the script fails.
On a single user PC I can manually disconnect the drive in their profile before setting up these scripts etc but on a multi-user PC, after removing their old local mapping batch file, I suppose I would have to use a NET USE /D in the All Users' profile startup folder instead to ensure each user would be OK before they try to run either scripts. I really don't want to add that extra layer of complexity to what is already a messy fudge!
How can I check for and remove these static mappings as part of my VBScript? It appears that the static mapping is visible under Win32_NetworkConnection but this does not provide a Disconnect Method. Am I going to have to use the WSH Shell object to run a net use /d if the NetworkConnection is found?
Any better ideas?
Thanks for reading!