risrollout Posted August 10, 2004 Share Posted August 10, 2004 Newbie question. How in Auotit do you check if a drive is already mapped before trying to map it? Looking thru the Forms and looking thru the Help files I see the DriveMapGet function and see that it will return a @error value. My question I guess is how do you write the If/Then statement to check if it is there then either map the drive or go on to the copy the files? I am cleaning up some logon scripts that have VBscript, Bat files, and some Exes and want to do it all in AutoIt so they can be compiled into one exe. Any help would be appriciated. Thank you. Link to comment Share on other sites More sharing options...
nobby Posted August 10, 2004 Share Posted August 10, 2004 Hey, Try this: DriveMapGet("f:") if @error = 1 then msgbox(0,"result", "NOT MAPPED") else msgbox(0,"result", "MAPPED") endif It works for me. CheersNobby Link to comment Share on other sites More sharing options...
Bartokv Posted August 10, 2004 Share Posted August 10, 2004 Okay, here's some untested code that may help out:$drives = DriveGetDrive("all") If NOT @error Then ; Performs check on each drive listed within system For $DriveNum = 1 to (Ubound($drives) - 1) $stat = DriveStatus($drives[$DriveNum]) MsgBox(4096, "Drive Status", "Drive " & $drives[DriveNum] & " is " & $stat) ; Only proceed if drive is readable If $stat == "READY" Then ; Do checks for active drives here EndIf Next EndIf EndFunc...I don't have AutoIt installed on this box (it's not mine), so I can't check if there are any bugs in the script.Also, keep in mind that most Windoze based systems have a "net use" command that lists the currently mapped drive names/locations.. You could also parse the output from this command if you wanted. Link to comment Share on other sites More sharing options...
pekster Posted August 10, 2004 Share Posted August 10, 2004 ...I don't have AutoIt installed on this box (it's not mine), so I can't check if there are any bugs in the script. <{POST_SNAPBACK}>You mean you don't have the AutoIt files on a CD or floppy or memory stick to use when you're on the go? [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
Bartokv Posted August 10, 2004 Share Posted August 10, 2004 You mean you don't have the AutoIt files on a CD or floppy or memory stick to use when you're on the go? Of course I had a copy of AutoIt! I was just working on a test machine, and didn't want to deal with all of the Corporate BS that goes along with installing unapproved software on a test box. Link to comment Share on other sites More sharing options...
this-is-me Posted August 11, 2004 Share Posted August 11, 2004 No install required, you know. Just drag the script to Autoit.exe Who else would I be? Link to comment Share on other sites More sharing options...
friends Posted August 13, 2004 Share Posted August 13, 2004 none of the above mentioned example works. mind to give a workable example ? very thanks Link to comment Share on other sites More sharing options...
this-is-me Posted August 13, 2004 Share Posted August 13, 2004 It might help if you give us an idea what version autoit you are using. Who else would I be? Link to comment Share on other sites More sharing options...
emmanuel Posted August 13, 2004 Share Posted August 13, 2004 (edited) if the goal is to make sure a user has a certain drive mapped, say Q: to a certain server, but to not remap if it's already mapped to something else, maybe something like this: $Idrive = DriveMapGet ("q:") if $idrive == "" then;drive not in use, so free to map it DriveMapAdd("q:", "\\server\share", 1);use your own option flags of course. Else MsgBox(0, "whatup?", "q: drive already in use by " & $Idrive) ;so do what you want to do. Do you want to disconnect it and change it to a new server? if $idrive = "\\olderserver\share" Then;say that \\olderserver was just replaced with \\server and you moved the share DriveMapDel("q:") DriveMapAdd("q:", "\\server\share", 1) EndIf EndIf Edited August 13, 2004 by emmanuel "I'm not even supposed to be here today!" -Dante (Hicks) Link to comment Share on other sites More sharing options...
risrollout Posted August 14, 2004 Author Share Posted August 14, 2004 What I am doing is cleaning up some log on scripts, and combining them into 1 Auotit exe. (if I can). I need to see if the I: drive is mapped and if it is not then map it. I want this to be done with out user intervention and silently. I am using AutoIt v3. Thanks for the responses and help. 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