We help IT Professionals succeed at work.

Need logon script to find all mapped drives

kind4me asked
Last Modified: 2012-05-05
Short story:  I need a script (and best way to run it GPO LOGON etc) to log all mapped drives and report it back to a network share.  

Long Story:

I am working for a client that had 10 servers (if putting a sticker that says "do not touch server" on a dell P4 makes it a server) running random shares.  I am removing 8 of these "servers" and installed a real server.  Since there is no logic behind what and where the shares are to begin with and most users have shares mapped staticly I need to know what people are connecting to.  A few years ago I created a script that run at logon and reported the mapped drives to a log file that was sent to a network share.  I have forgotten most of my scripting in that time and do not have the time to relearn it.  

Please help
Watch Question

the following script will give you the list of all mapped drives

strComputer = "."
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colDrives = objWMI.ExecQuery("select * from Win32_MappedLogicalDisk")
WScript.Echo "Mapped Drives:"
for each objDrive in colDrives
    WScript.Echo " Device ID: " & objDrive.DeviceID
    WScript.Echo " Volume Name: " & objDrive.VolumeName
    WScript.Echo " Session ID: " & objDrive.SessionID
    WScript.Echo " Size: " & objDrive.Size
oh and for log file you can see the following link ,, sorry I didnt mention that in my first post
found it from expers exchange !!!


Do you recomend running this as a logon script?  If so should I call it from the existing bat?


Sorry I wasn't clear, I need to know what server and share each user is connecting to.  

As for the log, I am not sure how to incorporate that into the other script.

This one is on us!
(Get your first solution completely free - no credit card required)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.