emmanuel Posted September 10, 2004 Share Posted September 10, 2004 I guess I just haven't figured out how to reference or set a multi-dimension array... I would like to create a single array that has the drive letters and paths of all network drives... Here's what I've got started: $alldrives = _drivemapgetall() for $i = 1 to $alldrives[0][0] MsgBox(4096,'debug:' , '$aMD:' & $alldrives[$i][$i]);### Debug MSGBOX Next Func _DriveMapGetAll ();returns an array of mapped network drives. $aDL = DriveGetDrive("NETWORK") dim $aMD[$aDL[0]][2] $aMD[0][0] = DriveGetDrive("NETWORK");drive letters for $l = 1 to $aMD[0][0] $aMD[$l][$l] = DriveMapGet($amd[$l]) Next Return $aMD EndFunc I'm really hoping that someone will smack me upside the head to drive home what I'm missing. "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Administrators Jon Posted September 10, 2004 Administrators Share Posted September 10, 2004 I guess I just haven't figured out how to reference or set a multi-dimension array... I would like to create a single array that has the drive letters and paths of all network drives... Here's what I've got started: $alldrives = _drivemapgetall() for $i = 1 to $alldrives[0][0] MsgBox(4096,'debug:' , '$aMD:' & $alldrives[$i][$i]);### Debug MSGBOX Next Func _DriveMapGetAll ();returns an array of mapped network drives. $aDL = DriveGetDrive("NETWORK") dim $aMD[$aDL[0]][2] $aMD[0][0] = DriveGetDrive("NETWORK");drive letters for $l = 1 to $aMD[0][0] $aMD[$l][$l] = DriveMapGet($amd[$l]) Next Return $aMD EndFunc I'm really hoping that someone will smack me upside the head to drive home what I'm missing. I think you've actually managed to create an array inside an array there I'll post a working version in a mo (unless JdeB beats me to it... ) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
emmanuel Posted September 10, 2004 Author Share Posted September 10, 2004 I think you've actually managed to create an array inside an array there I'll post a working version in a mo (unless JdeB beats me to it... ) <{POST_SNAPBACK}>yeah, see, this is me, confused. I'm really trying to grok the whole multi-dimension array deal, but am just not there. Searching the helpfile for array has not really helped... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Administrators Jon Posted September 10, 2004 Administrators Share Posted September 10, 2004 $alldrives = _drivemapgetall() For $i = 1 To $alldrives[0][0] MsgBox(4096, 'debug:', $alldrives[$i][0] & " is " & $alldrives[$i][1]) Next Func _DriveMapGetAll () $aDL = DriveGetDrive("NETWORK") $numdrives = $aDL[0] ;create new array big enough for all the drives plus mappings plus the "size" element Dim $aMD[$numdrives+1][2] ; Set [0][0] element to the number of drives $aMD[0][0] = $numdrives ; Populate each element with the drive and mapping For $l = 1 to $numdrives $aMD[$l][0] = $aDL[$l] $aMD[$l][1] = DriveMapGet($aDL[$l]) Next Return $aMD EndFunc Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
emmanuel Posted September 10, 2004 Author Share Posted September 10, 2004 Thank you Jon, that took you 1/3 the time to write a working script that it took me to write a broken one... And on the real plus side, I think I can use this to more fully understand how arrays work! Maybe someday I'll be all edumacated... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
Administrators Jon Posted September 10, 2004 Administrators Share Posted September 10, 2004 Thank you Jon, that took you 1/3 the time to write a working script that it took me to write a broken one... And on the real plus side, I think I can use this to more fully understand how arrays work! Maybe someday I'll be all edumacated... np. I sometimes find it easier to use temp variables, like $numdrives, to remove confusion. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted September 10, 2004 Administrators Share Posted September 10, 2004 (edited) If it helps, I think of 1 and 2 dimensional arrays as "tables". This is what I had in my head when I wrote that code. (this may either confuse or enlighten you ) Edited September 10, 2004 by Jon Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
emmanuel Posted September 10, 2004 Author Share Posted September 10, 2004 np. I sometimes find it easier to use temp variables, like $numdrives, to remove confusion. <{POST_SNAPBACK}>Yeah, that really helps make it more clear, and helps keep it from getting lost in the jumble. just in case you're curious, here's what I'm working towards with this script:Gather a list of existing network drivesRemap all of them as persistantLook for any drives mapped to a specified server and or share and remap them to a new server.Generate a textfile or other summery of actions taken, username, computername, etc.Perform actions based on command line options or ini file "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
emmanuel Posted September 10, 2004 Author Share Posted September 10, 2004 If it helps, I think of 1 and 2 dimensional arrays as "tables". This is what I had in my head when I wrote that code. (this may either confuse or enlighten you ) <{POST_SNAPBACK}>yeah, that does help, I was actually picturing it similarly, just didn't know how to get that out of my head and into reality... now I'm closer, I believe I understand and I'll see as I go forward with this script... I want to end up with something where you can specify a list of server/share names to replace old with new, to help when the shares are moved from server to server, as well as the simple task of taking all mapped drives and reconnecting them as persistant... "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
JLC123 Posted November 14, 2004 Share Posted November 14, 2004 (edited) I'm working on something very similar and was wondering if you had completed your script so I could take a peek. I need to: - gather a list of network drives - check to see if one of them is mapped to \\server\myserver - check to see what drive letters are not mapped and therefore available - if no dirve is mapped to \\server\myserver ask the user to select from the list of available drive letters and map it for them. Edited November 14, 2004 by JLC123 Two wrongs don't make a right, but three lefts do Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 14, 2004 Share Posted November 14, 2004 Sorry, but emmanuel hasn't been active on the board for about a month or more. Link to comment Share on other sites More sharing options...
JLC123 Posted November 14, 2004 Share Posted November 14, 2004 Figures. :-( I have the entire script written, but I hard coded it to a specific drive letter, not realizing at the time that some remote users deviate from the norm, or aren't properly mapped in the first place. I have the complete drive mapping piped out to a text file, now I just need to figure out how to search it for the \\server\myserver drive letter and then deal with the results. Two wrongs don't make a right, but three lefts do Link to comment Share on other sites More sharing options...
scriptkitty Posted November 15, 2004 Share Posted November 15, 2004 Might start by stringsplitting by \\ Can't actually split by more than one character, so look at this: $x="\\server\drive \\server2\drive \\server2\drive2 \\server\drive2 \\server3\drive" $y=StringReplace($x,"\\","|") $y=StringSplit($y,"|") for $i=1 to $y[0] $parts=StringSplit($y[$i],"\") if ubound($parts)=3 then msgbox(1, "Server="& $parts[1], "Share=" & $parts[2]) next AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now