Search the Community
Showing results for tags 'mappeddrives'.
Found 1 result
Hi all, I have a problem with a script when I run it as admin. I am trying to get all the mapped drives from the local pc. This is the script I am using ;~ #RequireAdmin ; This switch is going wrong #include <Array.au3> If isAdmin() then MsgBox(0,"ADMIN","ADMIN") Else MsgBox(0,"NOT ADMIN","NOT ADMIN") EndIf $x = getMappedDrives() _ArrayDisplay($x) Func getMappedDrives() Dim $aDrives $objWMIService = ObjGet("winmgmts:\\" & @LogonDomain & "\root\CIMV2") $sQuery = "Select * From Win32_LogicalDisk Where DriveType = 4" $colItems = $objWMIService.ExecQuery($sQuery, "WQL", 48) If IsObj($colItems) Then For $objItem In $colItems ReDim $aDrives[UBound($aDrives) + 1] $aDrives[UBound($aDrives) - 1] = $objItem.DeviceID $aDrives[UBound($aDrives) - 1] = $objItem.ProviderName Next Return $aDrives Else SetError(-1, -1, -1) EndIf EndFuncWhen I run it without the '#RequireAdmin' switch it works fine. When I turn on the '#RequireAdmin' switch is gives me an empty array. This code is part of a bigger project and my project always runs as admin. I dont know why it is doing this, because I am not using #RequireAdmin in the project. Is there an other better way to get the mapped drives that works for me? Or am I doing something wrong? I hope someone can help me. Regards, lrstndm