7 Replies Latest reply on Feb 5, 2009 8:25 PM by rsterling

    Finding drive mappings


      Has anyone got a decent, reliable method or script to detect all mapped drives?  I have the crude version below that works but reporting from this data collection isn't the easiest.


      Since we're movng from Novell to AD, I need to filter out my Novell mappings and only report on the non-Novell mappings.  I currently do this with an array of known Novell servers then searching their existence in the string of the found mappings, then liminating them.  Just looking for a better way.


      Thanks in advance!


        • 1. Re: Finding drive mappings

          How to capture a Client's mapped drives as part of its inventory.


          1. Using NOTEPAD or a text editor, open the file "LdAppl3.Template" in the core server's LDLOGON directory.
          2. Look for a section with the heading: [Registry Info], and paste the following lines into the space below the heading:


          Key=HKCU, Network\E, RemotePath, Mapped Drive E:
          Key=HKCU, Network\F, RemotePath, Mapped Drive F:
          Key=HKCU, Network\G, RemotePath, Mapped Drive G:
          Key=HKCU, Network\H, RemotePath, Mapped Drive H:
          Key=HKCU, Network\I, RemotePath, Mapped Drive I:
          Key=HKCU, Network\J, RemotePath, Mapped Drive J:
          Key=HKCU, Network\K, RemotePath, Mapped Drive K:
          Key=HKCU, Network\L, RemotePath, Mapped Drive L:
          Key=HKCU, Network\M, RemotePath, Mapped Drive M:
          Key=HKCU, Network\N, RemotePath, Mapped Drive N:
          Key=HKCU, Network\O, RemotePath, Mapped Drive O:
          Key=HKCU, Network\P, RemotePath, Mapped Drive P:
          Key=HKCU, Network\Q, RemotePath, Mapped Drive Q:
          Key=HKCU, Network\R, RemotePath, Mapped Drive R:
          Key=HKCU, Network\S, RemotePath, Mapped Drive S:
          Key=HKCU, Network\T, RemotePath, Mapped Drive T:
          Key=HKCU, Network\U, RemotePath, Mapped Drive U:
          Key=HKCU, Network\V, RemotePath, Mapped Drive V:
          Key=HKCU, Network\W, RemotePath, Mapped Drive W:
          Key=HKCU, Network\X, RemotePath, Mapped Drive X:
          Key=HKCU, Network\Y, RemotePath, Mapped Drive Y:
          Key=HKCU, Network\Z, RemotePath, Mapped Drive Z:


          3. Save the file, then open the core server's console utility and go to "Tools | Software License Monitoring"
          4. There will be a tool on the tool bar (third from the far right in LDMS 8.5) that makes changes available to all users. Click this tool.
          5. When computers submit inventory, if any drives (from E: - Z:) are mapped it will be recorded. Highlight the main "Computer" heading in the inventory summary, and in the right pane you will see an entry for each mapped drive it found and display the path it was mapped to.


          Keep in mind that these keys are under the Current User context, and as such will only be picked up by the inventory scanner if it runs while the user is logged in.

          • 2. Re: Finding drive mappings
            MarXtar ITSMMVPGroup

            For HKCU consider using the ldms_client utilities from http://www.droppedpackets.org for collecting this info.  I know you are aware of it Rich from previous discussions.


            Mark Star - MarXtar LANDesk Enhancements

            Home of Power State Notifier & Wake-On-WAN for LANDesk

            • 3. Re: Finding drive mappings

              Thanks folks, but i have no problem getting the data I need using my VBS (take a look at the previously attached vbs/txt) which I edit ldappl3 to pickup.  And all these mapped drives I then write to HKLM\area\of\my\choice to pick them up.  I just fire off the VBS with a BAT so I can opt to run as current user' account.  No problem.  The only issue is my section in ldappl3 needs 26 entries, one for every letter of the alphabet. ;Non-Novell Drives KEY=HKLM,Software\DCJS\LANDesk\Mappings,TotalMappings,Custom Data - Drive Mappings - Total Mappings KEY=HKLM,Software\DCJS\LANDesk\Mappings,TimeChecked,Custom Data - Drive Mappings - Time Checked KEY=HKLM,Software\DCJS\LANDesk\Mappings,0,Custom Data - Drive Mappings - 0 KEY=HKLM,Software\DCJS\LANDesk\Mappings,1,Custom Data - Drive Mappings - 1 KEY=HKLM,Software\DCJS\LANDesk\Mappings,2,Custom Data - Drive Mappings - 2 KEY=HKLM,Software\DCJS\LANDesk\Mappings,3,Custom Data - Drive Mappings - 3 KEY=HKLM,Software\DCJS\LANDesk\Mappings,4,Custom Data - Drive Mappings - 4  ... and so on. But the issue is querying out the data and producing a decent report. i.e, go to Network adapters, then network adapter... for each network adapter in the PC, you need only browse/choose one.  Due to the fact that I am writing unmodeled data, the data must go into the database redundantly (1 - 26 , A:-Z:), thus forcing me to write a seperate entry in ldappl (I can tailor the vbs to quit at the count of mappings).  It just all seems a bit messy.  Same principle as both mine and Jack's method to collect pst data.  See new attachments. My work around has been to create reports with the same redundancy and then set the fields to CAN SHRINK, but that.. like I say, although produces readable, valuable information - is just messy to build.  I guess what I'm asking is for a better way to model the data to avoid all the redundancy.

              • 4. Re: Finding drive mappings

                And just a quick note on HKCU, I find I get better results by getting the SID of the currently logged on user.  Hard to explain, but when the screen saver is active or the computer is sleeping.. or , 'err, well I guess I really dont have the explanation as to why but when I often try(ed) to pull data from HKCU, "CU" was considered as not available.  So I extract the SID for the currently logged on user (beleive me there is a difference) and then read HKU not HKCU..


                Set Users = objWMIService.InstancesOf ("Win32_ComputerSystem")

                ' Create the Shell object
                Set objShell = CreateObject ("WScript.Shell")

                For Each User In Users
                    logonname = User.UserName
                    strUsr = Split (logonname, "\")(1)
                    strDomain = Split (logonname, "\")(0)
                    Exit For

                Set colAccounts = objWMIService.ExecQuery _
                                  ("Select * From Win32_UserAccount where " _
                                  & "name = '" & strUsr & "' And domain = '" & strDomain & "'")

                For Each objAccount In colAccounts
                    strSID = objAccount.SID
                    Exit For

                '<*> Find current user's default profile
                strRoot =

                strSID & "\Software\Microsoft\Wherever...."

                • 5. Re: Finding drive mappings

                  I added a feature to ldms_client 2.4.1 to grab any mapped drives from HKCU, but I'm keeping an eye on Rich's methods. For one thing, I want to find a way to see attached network drives that don't have a mapped letter.

                  • 6. Re: Finding drive mappings
                    zman Master
                     $host = "." 
                      $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2") 
                      $colItems = $objWMIService.ExecQuery ("SELECT * from Win32_NetworkConnection") 
                      $conn = 0 
                      For $objItem in $colItems 
                          $conn += 1 
                          $info = "Name: " & $objItem.Name & @CRLF & "State: " & $objItem.ConnectionState & @CRLF & "Type: " & $objItem.ConnectionType & @CRLF & "Name: " & $objItem.LocalName & @CRLF & "Path: " & $objItem.RemotePath 
                          msgbox(0,"MAPPED " & $conn,$info) 

                    Autoit Code Shows Connections with no drive letter associated and state and does not read reg.

                    • 7. Re: Finding drive mappings

                      @ Jack - My script does that. I can do a start, run to \\myserver\myshare and NOT map a drive and it reports it. Save my txt file above as a vbs and run it.... We can also seperate the drive letter from the UNC patch by seperating:   


                      strValue = colDrives.Item(intDrive)_ & " " & colDrives.Item(intDrive +1)


                      as we write to the registry to read later..


                      But it's the whole "read later" thing that inspired this post.  Each time you add "+1" to any Integer in a VBS, it does just that, adds 1.  Therefore creating redundancy.  There's gotta be a better way to associate these for better, more accurate storage and reporting.


                      @Zman - Your script, as interpreted in my tiny little mind to vbs, will also do the same thing!


                      @ LANDesk Community Forum admin - All initial post compositions and subsequent editing in any format while on Vista and IE8 is not working very well for me!  Anyone else??? or is it just me?... (I know, new post, seperate forum)