Page 1 of 1 1
Topic Options
#104729 - 2003-09-03 09:05 PM Listing Remote Computer Network Drives
Zymurgy Offline
Lurker

Registered: 2003-09-03
Posts: 4
Loc: Charlotte, North Carolina
[Moderator (Sealeopard): Moved thread from 'Scripts' to 'General' forum due to lack of script in body]

I have the need to determine the user's mapped network drives.

I can parse Active Directory to get each computer in the enterprise and in turn, need to ascertain the current user's mapped drives.

I have tried WSH & WMI, but neither will provide the information on remote computer drives.

I have searched the UDF's & a large portion of the UBB but cannot find the information to get this going.

I am sure that this has been done, I just am not able to find the script/UDF to do this. Any assistance or suggestions are most welcome.
[Smile]

[ 17. September 2003, 19:11: Message edited by: sealeopard ]

Top
#104730 - 2003-09-03 09:19 PM Re: Listing Remote Computer Network Drives
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
All mapped drives are listed in: HKEY_CURRENT_USER\Network.

Enumerating the keys below HKEY_CURRENT_USER\Network and writing this to some file could be done at logon.

code:
$Index = 0
:Loop1
$drives = EnumKey("HKEY_CURRENT_USER\Network", $Index)
If @ERROR = 0
ReDirectOutput ("c:\drives.log", 0) ; 0 to append to file. 1 to overwrite
? "Drive found: $drives"
$Index = $Index + 1
Goto Loop1
EndIf

Doing this remote is also possible.
code:
$Index = 0
:Loop1
$drives = EnumKey("\\workstationname\HKEY_CURRENT_USER\Network", $Index)
If @ERROR = 0
ReDirectOutput ("c:\drives.log", 0) ; 0 to append to file. 1 to overwrite
? "Drive found: $drives"
$Index = $Index + 1
Goto Loop1
EndIf

Both quoted from the manual and altered a little.

@error will be 0 until all keys are enumerated. Script will stop when error is different then 0.

[ 03. September 2003, 21:44: Message edited by: R2D2 ]
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#104731 - 2003-09-03 09:55 PM Re: Listing Remote Computer Network Drives
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
quote:
All mapped drives are listed in: HKEY_CURRENT_USER\Network.

This key actually contains the drives that are persistently mapped. If drives mapped through login script or via direct mapping (i.e. Home Folder) this key will not contain those mappings.

Top
#104732 - 2003-09-03 10:04 PM Re: Listing Remote Computer Network Drives
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
All the drives mapped by our logon script show up here.
Mapping drives with net use x: \\servers\share also shows up here. The homeshare mapped by the user manager actually does not show up indeed.

Another example from the manual:

code:
$Drives = GetObject("winmgmts:").ExecQuery("select Name,DriveType from Win32_LogicalDisk")

If @error <> 0
? @error + " / " @serror
Else
For Each $Drive in $Drives
? $Drive.Name
Next
EndIf

This does show all drives. Removing local disks should be possible I guess but I’m not realy into WMI and COM (yet).

[ 03. September 2003, 22:06: Message edited by: R2D2 ]
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#104733 - 2003-09-04 12:10 AM Re: Listing Remote Computer Network Drives
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I believe what Chris stated above only applies to Windows XP. Only my one persistent mapped drive shows up there for me.
Top
#104734 - 2003-09-08 01:53 PM Re: Listing Remote Computer Network Drives
Zymurgy Offline
Lurker

Registered: 2003-09-03
Posts: 4
Loc: Charlotte, North Carolina
[Smile]
Thanks for the help, I used the WMI provider for Logical Disk to parse the user's drives and get a list. I tried the logon script approach, but it slowed the users down enough to complain about logon times, therefore I removed it and went fully remote via WMI.

The only caveat is that the Win32_LogicalDisk will not provide a list of drives that are temporarily disconnected (ie. the user hasn't accessed the drive mapping, and thier connection state is recycled, disconnected). But, I hit at least an 80% success rate.

Tks,
Z [Smile]

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.05 seconds in which 0.011 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org