fox_91 Posted March 8, 2005 Posted March 8, 2005 Hello, im kinda new to AutoIt, ive used it for some simple scripts but now we use it a work a little to automate some tasks, im trying to get this code to map a student's network drive in one of 3 ways, they can map 2 drives that students use most often, and theres a box for them to specify lesser ussed servers/shares.... i used the help file and tried to write this script, which works, but when the start button is clicked it says its finished, but it never maps a drive or errors or anything that would indicate that it works... ive tried to simply use some easy data to map somthing but nothing seems to work... could someone take a glance and see if i have some glaring error... thanks #include <GUIConstants.au3> GUICreate("Network Mapping Script",300,200) ; will create a dialog box that when displayed is centered GUICtrlCreateLabel ("Enter Username", 10, 5, 100,20) $username = GUICtrlCreateInput ( "", 115, 5, 80, 20) GUICtrlCreateLabel ("Enter Login Password", 10, 30, 110,20) $password = GUICtrlCreateInput ( "", 115, 30, 80, 20, $ES_PASSWORD) $check1 = GUICtrlCreateCheckbox ("\\beyer\"&$username, 10, 75, 150, 20) $check2 = GUICtrlCreateCheckbox ("\\beyer\gushare", 10, 95, 100, 20) $check3 = GUICtrlCreateCheckbox ("Other", 10, 115, 60, 20) $path = GUICtrlCreateInput ( "Enter Path", 100, 115, 100, 20) $go=GUICtrlCreateButton ("MAP IT",150,150,70,20) GUICtrlSetState(-1,$GUI_FOCUS) ; the focus is on this button GUISetState () ; will display an empty dialog box ; Run the GUI until the dialog is closed ;GUISetState() Do $msg = GUIGetMsg() if $msg = $go then if (guictrlread($check1)) = 1 then DriveMapAdd ("*", "\\beyer\"&$username ,0,$username, $password) EndIf if (guictrlread($check2)) = 1 Then DriveMapAdd ("*", "\\beyer\GUSHARE",8,$username, $password) EndIf if (guictrlread($check3)) = 1 Then DriveMapAdd ("*", $path, 0,$username, $password) EndIf msgbox ("All Done", "All Done", "Thank You Come Again") EndIf Until $msg = $GUI_EVENT_CLOSE
CyberSlug Posted March 8, 2005 Posted March 8, 2005 Have you checked the return values of the DriveMapAdd? $debug = DriveMapAdd(.....) MsgBox(4096,"Debug", $debug) Off the top of my head: 1) Make sure users have enough local permissions to map a drive. (Can they right-click My Computer, choose Map Network drive, and successfully map something?) 2) Do you need to specify a domain with the username? $username = "DOMAIN\usr" Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
fox_91 Posted March 8, 2005 Author Posted March 8, 2005 Have you checked the return values of the DriveMapAdd?$debug = DriveMapAdd(.....)MsgBox(4096,"Debug", $debug)Off the top of my head:1) Make sure users have enough local permissions to map a drive. (Can they right-click My Computer, choose Map Network drive, and successfully map something?)2) Do you need to specify a domain with the username?$username = "DOMAIN\usr"<{POST_SNAPBACK}>When i used your debug code, i just get a blank msgbox like it doesn't assign a value to $debug, tho i don't know what it would assign to it.1) right now i have been trying it on my local machine, that wouldnt have those permission problems that you speak of, so i don't think that is at fault.2)same as 1. i should be able to make a share local with hard coded, path, but it doens't seem to go.
CyberSlug Posted March 8, 2005 Posted March 8, 2005 When i used your debug code, i just get a blank msgbox like it doesn't assign a value to $debug, tho i don't know what it would assign to it.<{POST_SNAPBACK}>The debugs should have returned the number 1 or 0. Actually, I should have told you to check the @error value. Just to make sure we are on the same page:$msg = GUIGetMsg()if $msg = $go thenif (guictrlread($check1)) = 1 thenDriveMapAdd ("*", "\\beyer\"&$username ,0,$username, $password)Msgbox(4096,"Debug", @error)EndIfif (guictrlread($check2)) = 1 ThenDriveMapAdd ("*", "\\beyer\GUSHARE",8,$username, $password)Msgbox(4096,"Debug", @error)EndIfif (guictrlread($check3)) = 1 ThenDriveMapAdd ("*", $path, 0,$username, $password)Msgbox(4096,"Debug", @error)EndIfmsgbox ("All Done", "All Done", "Thank You Come Again") Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
fox_91 Posted March 8, 2005 Author Posted March 8, 2005 The debugs should have returned the number 1 or 0. Actually, I should have told you to check the @error value. Just to make sure we are on the same page:$msg = GUIGetMsg()if $msg = $go thenif (guictrlread($check1)) = 1 thenDriveMapAdd ("*", "\\beyer\"&$username ,0,$username, $password)Msgbox(4096,"Debug", @error)EndIfif (guictrlread($check2)) = 1 ThenDriveMapAdd ("*", "\\beyer\GUSHARE",8,$username, $password)Msgbox(4096,"Debug", @error)EndIfif (guictrlread($check3)) = 1 ThenDriveMapAdd ("*", $path, 0,$username, $password)Msgbox(4096,"Debug", @error)EndIfmsgbox ("All Done", "All Done", "Thank You Come Again")<{POST_SNAPBACK}>well i tried the debug line, and lucky me i got a 1 as the error, which as i recalled from the help file says Misc Error. hmm, is there somthing wrong with the line?
CyberSlug Posted March 8, 2005 Posted March 8, 2005 Ah, I see what we are overlooking: $username = GUICtrlCreateInput ( "", 115, 5, 80, 20) The $username variable is a control reference. If we want the text that the user typed into the input box, then we need GuiCtrlRead($username) expandcollapse popup#include <GUIConstants.au3> $GUI = GUICreate("Network Mapping Script",300,200); will create a dialog box that when displayed is centered GUICtrlCreateLabel ("Enter Username", 10, 5, 100,20) $input_username = GUICtrlCreateInput ( "", 115, 5, 80, 20) GUICtrlCreateLabel ("Enter Login Password", 10, 30, 110,20) $input_password = GUICtrlCreateInput ( "", 115, 30, 80, 20, $ES_PASSWORD) $check1 = GUICtrlCreateCheckbox ("\\beyer\", 10, 75, 150, 20) $check2 = GUICtrlCreateCheckbox ("\\beyer\gushare", 10, 95, 100, 20) $check3 = GUICtrlCreateCheckbox ("Other", 10, 115, 60, 20) $path = GUICtrlCreateInput ( "Enter Path", 100, 115, 100, 20) $go=GUICtrlCreateButton ("MAP IT",150,150,70,20) GUICtrlSetState(-1,$GUI_FOCUS); the focus is on this button GUISetState (); will display an empty dialog box ; Run the GUI until the dialog is closed ;GUISetState() Do $msg = GUIGetMsg() If ControlGetText($GUI,"",$check1) <> "\\beyer\" & GuiCtrlRead($input_username) Then ;update path in first checkbox GuiCtrlSetData($check1, "\\beyer\" & GuiCtrlRead($input_username)) EndIf if $msg = $go then $username = GuiCtrlRead($input_username) $password = GuiCtrlRead($input_password) if (guictrlread($check1)) = 1 then DriveMapAdd ("*", "\\beyer\" & $username, 0, $username, $password) EndIf if (guictrlread($check2)) = 1 Then DriveMapAdd ("*", "\\beyer\GUSHARE", 8, $username, $password) EndIf if (guictrlread($check3)) = 1 Then DriveMapAdd ("*", $path, 0, $username, $password) EndIf msgbox ("All Done", "All Done", "Thank You Come Again") EndIf Until $msg = $GUI_EVENT_CLOSE Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
fox_91 Posted March 8, 2005 Author Posted March 8, 2005 lol, i will try that ctrlRead today, hope that works, thank you
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