Jump to content

Writing drive mappings to an array


Recommended Posts

Sorry about the ambiguous title but I will try to explain what I am doing.

I need to read a users drive mappings (the server path & letter its mapped to) and then do a check to find a particular drive and respond back with the mapped letter.

For instance:

$var = DriveGetDrive( "all" )
If NOT @error Then
    For $i = 1 to $var[0]
        ConsoleWrite($var[$i]& " " & DriveMapGet ($var[$i]) & @CRLF)
    Next
EndIf

This will display all the drives with the paths mapped. What I need to do is run a check after to see which drive is the users personal network folder.

I have tried to read up on multi arrays but cannot quite grasp how to dump the data into the multidimensional array (it would only require 2 columns)so it would look like this:

drive | mapping |

c:

d:

i: \\LON5\IT$

k: \\LON6\LUC

m: \\LON5\MIS$

r: \\LON5\DEVELOP$

s: \\LON5\ISD$

u: \\LON5\gbxxxx$

w: \\LON5\NETAPPS

Once its in the array, I would need to check which letter was mapped to the users ID (@username). In the above example: gbxxx$ = U.

Any and all help is appreciated!

Thanks

Chris

Edited by makeinstall
Link to comment
Share on other sites

Here is one way

#include <array.au3>
$Var = DriveGetDrive("all")
If Not @error Then
    Local $2DArray[$Var[0] + 1][2]
    ;$2DArray[0][0] = $var[0]   uncomment and comment out line 14 if you want Drive Count
    For $i = 1 To $Var[0]
        $2DArray[$i][0] = $Var[$i]
        If DriveMapGet($Var[$i]) Then 
            $2DArray[$i][1] = DriveMapGet($Var[$i])
        Else
            $2DArray[$i][1] = DriveGetLabel($Var[$i])
        EndIf
    Next
    _ArrayDelete($2DArray, 0)   ;comment out and uncomment line 5 if you want Drive Count
    _ArrayDisplay($2DArray)
EndIf

Link to comment
Share on other sites

Thanks for the reply and help. I've been working through that code to try and understand the whole 2D array so that I can create & manipulate myself in future.

A bizarre thing is happening now in that I'm writing some code to search the array but the auto complete in SCiTE doesn't seem to be aware of Array UDF. It sees _ArrayDelete & _ArrayDisplay but none of the others, especially _ArraySearch (See attached screencap). I've tried reinstalling SCiTE but it doesn't resolve it.

Weirdness!

post-47203-12837739812882_thumb.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...