Jump to content

Recommended Posts

Posted (edited)

Knocked-up a quick script to simplify the maintenance of login-scripts.

Basically, we have a number of departments, some of which have only selective access to certain areas of the servers. (Nothing unusual there..) Maintaining a separate login-script for each of these departments was getting to be a pain, yet was preferable to using a single script, which would confuse the users by placing inaccessible drive-mappings on their machines. So thought it might be a lot simpler to map all drives from a common script, then check each for accessibility and remove those for which a directory-listing is denied.

; ******** DriveZap.au3 ************ 

$letters=stringsplit("h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,-",",")

$ct=1
while $letters[$ct]<>"-"
 $letters[$ct]=$letters[$ct] & ":"
 $share=drivemapget($letters[$ct]) 
 if $share <> "" then
  $handle=filefindfirstfile($share & "\*") 
  if $handle < 0 then
   drivemapdel($letters[$ct]) 
  else
   fileclose($handle)
  endif
 endif
 $ct=$ct+1
wend

This method works, but might not be the most efficient one possible. It relies on the "./.." entries being visible if the folder contains no other files. Thoughts on this, anyone?

Edited by IanR

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...