我如何知道用户映射了哪些网络驱动器?

spo*_*son 5 networking windows

扫描以查找为域中所有桌面上的所有登录用户设置的驱动器映射的最佳方法是什么?这将用于确定环境中正在使用的驱动器号。

这是在 Active Directory 2003 域内的企业环境中。我目前使用运行“净使用”和管道到日志文件的 SMS 2003 广告。点击每个桌面需要很长时间。有没有更好的办法?

spo*_*son 1

所有这些答案都是让我继续前进的很好的线索。谢谢。

我偶然发现了这个 VBScript 示例,它完全符合我的要求并且运行良好。

这是该帖子的代码片段:

'Define variables, constants and objects

strComputer="REMOTE MACHINE HERE"
Const HKEY_USERS = &H80000003
Set objWbem = GetObject("winmgmts:")
Set objRegistry = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
Set objWMIService = GetObject("winmgmts:"  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Go and get the currently logged on user by checking the owner of the Explorer.exe process.  

Set colProc = objWmiService.ExecQuery("Select Name from Win32_Process" & " Where Name='explorer.exe' and SessionID=0")

If colProc.Count > 0 Then
   For Each oProcess In colProc
       oProcess.GetOwner sUser, sDomain
   Next
End If

'Loop through the HKEY_USERS hive until (ignoring the .DEFAULT and _CLASSES trees) until we find the tree that 
'corresponds to the currently logged on user.
lngRtn = objRegistry.EnumKey(HKEY_USERS, "", arrRegKeys)    

For Each strKey In arrRegKeys
   If UCase(strKey) = ".DEFAULT" Or UCase(Right(strKey, 8)) = "_CLASSES" Then
   Else

       Set objSID = objWbem.Get("Win32_SID.SID='" & strKey & "'")

'If the account name of the current sid we're checking matches the accountname we're looking for Then
'enumerate the Network subtree
       If objSID.accountname = sUser Then 
           regpath2enumerate = strkey & "\Network" 'strkey is the SID
           objRegistry.enumkey hkey_users, regpath2enumerate, arrkeynames

'If the array has elements, go and get the drives info from the registry
           If Not (IsEmpty(arrkeynames)) Then
               For Each subkey In arrkeynames
                   regpath = strkey & "\Network\" & subkey
                   regentry = "RemotePath"
                   objRegistry.getstringvalue hkey_users, regpath, regentry, dapath
                   wscript.echo subkey & ":" & vbTab & dapath
               Next
           End If
       End If
   End If
Next
Run Code Online (Sandbox Code Playgroud)