Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Retrieving Mapped drives not working in System account

$
0
0

Hello Team, Greeting All!

My aim is to retrieve the list of mapped drives in users computer. I am using the below code to achieve this, When I use my vbscript with user account it works, whereas if I run the same in system account, it didn't work for me. Could you help me out this..

---------------------------------------------------------------------------------------------------------------------------------------------

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colDrives = objWMIService.ExecQuery _
    ("Select * From Win32_LogicalDisk Where DriveType = 4")

For Each objDrive in colDrives
    ObjLogfile.write objDrive.DeviceID
    ObjLogfile.write " " & objDrive.ProviderName & vbCrLf
Next

---------------------------------------------------------------------------------------------------------------------------------------------

Thanks for your help in advance!!

Regards,


-RC


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>