scripting - Clean Up Disconnected Network Drives -


i have app requires connection remote windows. have done use mapped drive build connection on windows startup menu. partial codes this:

 @if not exist \\remotepc\sharedfolder net use * \\remotepc\sharedfolder /user:user1 pwd /persistent:yes 

the net use map works fine. mapped drive 1 available network drive letters. in app, unc name used instead(\remotepc\sharedfolder).

the issue(not sure issue) after several reboots, can see list of disconnected drivers file explorer:

enter image description here

i not sure letters used if reboot pc many times? clean disconnected network drives. can batch script? tried use net use again disconnected drive, deletes ok first time, stays in file explorer.

net use t: /delete 

notes: not sure usage of option /persistent:yes. think should reconnect network drive after log in or reboot. not happen. that's why added scripts start menu. realize other file explorer tools display disconnected network drives. each time reboot, 1 more disconnected network drive appears. seems disconnected network drives exists in windows. there way in scripts find them , clean them?

update: run test 10 times , stage no more letter available network drive mapping. here snap-shot of network drive status using total commander:

enter image description here

if right click on disconnected network drives, can disconnect them. there must way make disconnected ones available. however, not released use net /delete command:

net use x: /delete 

the disconnected ones caused reboot or logout. seems have no control on them since 1) use dynamic mapping, , 2)no place plugin script before reboot or logout. 1 way can think reconnect using following command (simplified one):

if not exist y:\ net use \\remotepc\shared... 

where y: may loop. above simplified one. tried cmd , works.

however before put loop batch script, prefer clean disconnected ones. comes way: add scripts batch in start clean up. if there script codes or tools available can use in batch script make disconnected ones available?

i think figure out solution. in mapping script, instead of yes persistent, should use no:

net use * \\remotepc\sharedfolder /user:user1 pwd /persistent:no 

this option tells windows not keep network drive persistent reconnection(you click on broken 1 file explorer back). result, when user login again after logout or reboot, network drive not in list of disconnected ones. i'll not run issue of running out of network drive letters.

actually work colleague helped me solution, , share people have interest in issue.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -