Home | Download | Demo | Feature list | Premium users | Support | Knowledgebase
How to fix WMI Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
The network path was not found - The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
How to configure Windows Vista clients.
How to configure the windows firewall using group policies.
   
Welcome Guest Search | Active Topics | Members | Log In | Register

mapped network drives path Options
ejensen
Posted: Tuesday, May 13, 2008 4:51:51 PM
Rank: Freeware Member
Groups: Member

Joined: 5/2/2008
Posts: 26
Location: Ohio, USA
would be nice to know what path network drives are mapped to.

also, would be nice to see free space as a percentage.
ejensen
Posted: Thursday, June 19, 2008 2:52:06 PM
Rank: Freeware Member
Groups: Member

Joined: 5/2/2008
Posts: 26
Location: Ohio, USA
here is part of a script that should get us started on adding mapped drives for users on a computer.
I will dig through some other scripts to see what else might be needed.

This only shows persistent mapped drives I believe.

Code:

'Searching the registry for stored profiles
strKeyPath = ""
oReg.EnumKey HKEY_USERS, strKeyPath, arrSubKeys
For Each subkey In arrSubKeys
  ' Filtering out some well-known SIDs
  Select Case subkey
    Case ".DEFAULT"
    Case "S-1-5-18" 'Local System
    Case "S-1-5-19" 'Local Service
    Case "S-1-5-20" 'Network service
    Case Else
           If Instr(subkey, "_Classes") = 0 Then
             'Searching for mapped drives   
             strKeyPath2 = subkey & "\Network"
             oReg.EnumKey HKEY_USERS, strKeyPath2, arrSubKeys2
             For Each subkey2 in arrSubKeys2
               If subkey2 <> "" Then
                 'Found mapped drive
                 'Searching for the username matching the SID
                 DeviceID = ""
                 ProviderName = ""
                 MapUserName = ""
                 MapUserDomain = ""
                 ConnectAs = ""
                 Set colItems = objWMIService.ExecQuery("Select Name, Domain from Win32_UserAccount where SID = '" & subkey & "'",,48)
                 If colItems <> "" Then
                   ' Found local user
                   For Each objItem in colItems
                     MapUserName = objItem.Domain & "\" & objItem.Name
                   Next
                 End If
                 If MapUserName = "" Then
                   'Searching the registry for domain user info
                   strKeyPath3 = subkey & "\Software\Microsoft\Windows\CurrentVersion\Explorer"
                   oReg.GetStringValue HKEY_USERS, strKeyPath3, "Logon User name", MapUserName
                   strKeyPath4 = subkey & "\Volatile Environment"
                   oReg.GetStringValue HKEY_USERS, strKeyPath4, "USERDNSDOMAIN", MapUserDomain
                   MapUserName = MapUserName & "@" & LCase(MapUserDomain)
                 End If
                 'Reading  mapped drive details
                 DeviceId = Ucase(subkey2)
                 strKeyPath5 = strKeyPath2 & "\" & subkey2
                 oReg.GetStringValue HKEY_USERS, strKeyPath5, "RemotePath", ProviderName
                 oReg.GetStringValue HKEY_USERS, strKeyPath5, "UserName", ConnectAs
                 FileSystem = ""
                 FreeSpace = 0
                 Size = 0
                 form_input = "mapped^^^" & DeviceID  & "^^^"  & FileSystem   & "^^^"  & FreeSpace  & "^^^"  & ProviderName  & "^^^"  _
                                          & Size      & "^^^"  & MapUserName  & "^^^"  & ConnectAs  & "^^^"
                 entry form_input,comment,objTextFile,oAdd,oComment
                 form_input = ""
               End If 'subkey2 <> ""
             Next 'subkey2 in arrSubKeys2
           End If 'Instr(subkey, "_Classes") = 0
  End Select
Next ' subkey In arrSubKeys
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.


Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.

   
Quick links: Download - Premium users - Support 
Copyright 2004 - 2008 © Geert Moernaut - Hemoco bvba - All rights reserved