mdcros.blogg.se

Mapped drives registry
Mapped drives registry









mapped drives registry

Set objTextFile = objFSO.OpenTextFile(bFile, 2, True) ' 2 = writing Set objTextFile = objFSO.OpenTextFile(bFile, 8, True) ' 8 = appending StrComputerName = lcase(objEnv("COMPUTERNAME"))īPath = "\\servername\sharename" ' Server and path to save filesīFile = bPath & "\" & strComputerName &"-" & strUserName & "-NetDrives.txt" Set objNetwork = CreateObject("WScript.Network") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objEnv = objShell.Environment("Process") Set objShell = CreateObject("WScript.shell") We're running an exercise to discover all user's mapped drives at the moment, and are running a script like this in each user's context to get that info and dump down to a network share where we can grab the files and parse them with another script later: scriptVersion = "1.0" That obviously only lists them for the current logged on user on the machine that it's run on. Wscript.Echo colDrives.Item(i) & vbTab & colDrives.Item (i + 1)

mapped drives registry

Set colDrives = objNetwork.EnumNetworkDrives In WMI/VBScript the bit you need to list out the current user's mapped drives is: Set objNetwork = WScript.CreateObject("WScript.Network") Each user who has a profile on the target machine has a copy of their HKCU key saved under a key named with their SID, you need to find the right one and then pull the Network key information from under that.

#MAPPED DRIVES REGISTRY HOW TO#

If you want to pursue this using some Powershell scripting there's a sample script on this blog post by Hugo Peeters that shows how to connect to a remote registry but you will have to figure out how to map the username to their SID so you can choose the correct key under HKEY_USERS. Throw that into a logon script and you have a regularly refreshed copy but obviously you don't want to do that if you really don't need the info. Then you just look in the share for the Username.drives file for a precise copy of what you need. If this is a regular support issue then why not provide them with a link to a batch file that does something like: Net use > \\someserver\someshare\%username%.drives That's going to be a bit of work and could be quite slow if you intend to do it a lot. The biggest problem with this approach is that you have to either connect remotely to the users machine while they are logged in or connect and enumerate the user profiles, map those to SID's and then search in the relevant Key beneath HKEY_USERS to find the relevant copy of the users hive.

mapped drives registry

The keys will only exist for Persistent connections, I don't think you can find transient mappings in the registry. The properties of the mapping are contained in values - the ones you are most likely to be interested in are: RemotePath REG_SZ The keys you're looking for are located here: \\HKCU\NetworkĮach mapped drive is represented by a Registry key named for the drive letter.











Mapped drives registry