[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4152
  • Last Modified:

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!
0
jasgiv1122
Asked:
jasgiv1122
  • 5
  • 4
2 Solutions
 
jharrell2Commented:
why not just use:
net use y: /Delete
as a login script for everyone for a few weeks?
0
 
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.
0
 
jharrell2Commented:
how many users are we talking about? Also, are you running AD?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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.
0
 
jharrell2Commented:
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.
0
 
jharrell2Commented:
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
0
 
jasgiv1122Author 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.
0
 
TonyStCommented:
Add a login script for each user
in the script put

Net USE * /DELETE /Y
0
 
jharrell2Commented:
That was mentioned earlier, read my first comment
0
 
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now