How do I remotely delete a mapped drive?
Posted on 2009-04-28
We have multiple windows 2000 machines that upon being restarted, will error because they have a mapped network drive back to the server. Without having access to the machines (only the server), I have to delete the mapped drive for each. It was left on the machines from a psexec command that didn't delete the drive before it ended. With psexec, if you start a new session, it won't recognize things in previous psexec sessions, so I can't use that to delete the mapped drive. I've tried multiple times and it doesn't even see that anything is mapped (I tried the system account, administrator account etc). I have a test setup with a server and a test machine to see if it will work before I send it out to all of the win2000 machines.
One way I have found that looks like it may work, is to use the registry. From the server, using network registry, I can see the mapped drives per lane.
\\client\Hkey_Users\S-1-5-21-1123(goes on for about 15 more numbers)\Network\y
if I delete y (which is the letter that is mapped on all these clients), then reboot the machines, they reboot just fine. So my goal is to either use the Reg Delete (although I hear wildcards won't work in this) or regdelete in vbscript to delete the y mapped drive in all of the machines. I need to bypass the user number though, because its different for every lane... So essentially (I know it wont work, but this is along the lines of what i need) I need to have something like this:
reg delete \\client\Hkey_Users\*\Network\y /f
If it needs to be something more advanced than this, I'm willing to try anything. Whether that is querying or script, doesnt matter. Thanks for any help!