How do I remotely delete a mapped drive?

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!
Who is Participating?
jasgiv1122Connect With a Mentor Author Commented:
psexec didn't work for me.  I logged in with the user on that machine and it said that there were no mapped connections.  Then if I tried to map a drive to y:, it said it was in use.

I actually have something that I just tested and it worked!  Thanks for your help!!  

for /f %%a in ('REG QUERY \\client\HKU ^|Findstr /R "S-1-5-[0-9]*-[0-9-]*$"') do (
reg delete \\client\%%a\Network\y /f

This came up and edited the registry setting I wanted to take care of.
why not just use:
net use y: /Delete
as a login script for everyone for a few weeks?
jasgiv1122Author Commented:
The clients will fail on reboot and get the network error...  They won't reboot for weeks, so I need to fix it from the server, before they are rebooted.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

how many users are we talking about? Also, are you running AD?
jasgiv1122Author Commented:
it's anywhere from 3-7 individual computers that autologin and are connected to a single server.  They are all having this mapping issue.
jharrell2Connect With a Mentor Commented:
If these machines are not on a domain and being less than 10 machines (i'm assuming the autologin account is the only one affected).  I believe psexec is your best bet.  I have scripts that utilize psexec, but you should be able to do this in a matter of minutes just from command line:

psexec.exe \\computer1 -u computer1\autologinuser -p autologinuserspassword "command to run"

so it should look something like this for each machine:

psexec.exe \\computer1 -u computer1\autologinuser -p autologinuserspassword "REG Delete HKCU\Network\y"

As long as you login with the account that does the autologin you'll pass the Hkey Current User as the path.  If you login as any other user (or dont supply the -u or -p switches in psexec) you'll need to enter the ID's of the user, so its really easier just to pass the login info with the psexec command and delete the HKCU\network path instead of hkey_users s-12341231451-12-41-23-515123 etc.
actually... if you're able to login as that user with psexec you can just run 'net use y: /Delete' as opposed to running 'reg delete' commands
Add a login script for each user
in the script put

That was mentioned earlier, read my first comment
jasgiv1122Author Commented:
The users are already signed in and won't be signed out.  I understand the net use commands and that if I use a login script, it will take care of the issue... but the users can't be signed out without getting this issue, and the can't be rebooted without getting the issue.  This is resolved.  Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.