stev379 0 Posted February 10, 2005 Share Posted February 10, 2005 This works except it tries to map the drive whether the checkboxes are checked or not. How can I get it to map the selected drive only if the corrosponding checkbox is checked? Thanks for any help! #include <GUIConstants.au3> #include <Constants.au3> Global $Label_1, $Label_2, $Label_3, $Input_AdmPW, $Input_UsrNM, $Input_UsrPW, _ $Button_OK, $Button_Cancel, $msg, $AdmPW, $UsrNM, $UsrPW, $success GUICreate("Drive Mapping", 400, 280) $Input_DrvLtr1 = GuiCtrlCreateInput("", 150, 25, 30, 20,) GuiCtrlSetState($Input_DrvLtr1, $GUI_FOCUS) ;start with cursor in this textbox $Input_DrvLtr2 = GuiCtrlCreateInput("", 150, 50, 30, 20,) ;OTHER DRIVE INPUT $Input_DrvLtr3 = GuiCtrlCreateInput("", 150, 75, 30, 20,) $Input_DrvPath3 = GuiCtrlCreateInput("", 190, 75, 165, 20) GUICtrlSetData(-1,"Enter other drive path if wanted") ;CHECKBOXES GUICtrlCreateGroup("Select path and enter drive letter", 4, 4, 360, 210) $Drv1=GUICtrlCreateCheckbox("\\Server1\Share1",25,25) GuiCtrlSetState($Drv1, $GUI_CHECKED) $Drv2=GUICtrlCreateCheckbox("\\Server1\Share1\Shr2",25,50) $Drv3=GUICtrlCreateCheckbox("Other:",25,75) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group $UsrNM = GuiCtrlCreateLabel("Domain user name: ", 15, 120, 110, 20, $SS_RIGHT) $UsrPW = GuiCtrlCreateLabel("Domain user password: ", 5, 145, 127, 20, $SS_RIGHT) $Input_UsrNM = GuiCtrlCreateInput("", 150, 120, 205, 20) $Input_UsrPW = GuiCtrlCreateInput("", 150, 145, 205, 20, $ES_PASSWORD) $Button_OK = GuiCtrlCreateButton("OK", 65, 170, 70, 30) GuiCtrlSetState($Button_OK, $GUI_DEFBUTTON) $Button_Cancel = GuiCtrlCreateButton("&Cancel", 280, 170, 70, 30) GUISetState () ; will display an empty dialog box While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_Cancel ExitLoop Case $msg = $Button_OK $DrvLtr = GuiCtrlRead($Input_DrvLtr1) $DrvLtr2 = GuiCtrlRead($Input_DrvLtr2) $UsrNM = GuiCtrlRead($Input_UsrNM) $UsrPW = GUICtrlRead($Input_UsrPW) Opt("RunErrorsFatal", 0);don't crash script RunAsSet("Administrator", @Computername, $DrvLtr) $success = DriveMapAdd($DrvLtr & ":", "\\Server1\Share1", 0, "nih\" & $UsrNm, $UsrPW) If $success Then MsgBox(4096,"Done", $DrvLtr & ": Drive mapped to \\Server1\Share1") GuiCtrlSetData($Input_DrvLtr1, "") GuiCtrlSetState($Input_UsrNM, $GUI_FOCUS) ;start with cursor in this textbox GuiCtrlSetData($Input_UsrPW, "") Else MsgBox(4096,"Error", "Error mapping drive...") GuiCtrlSetState($Input_UsrNM, $GUI_FOCUS) ;start with cursor in this textbox EndIf If $DrvLtr2 = "" Then Exit Else RunAsSet("Administrator", @Computername, $DrvLtr2) $success2 = DriveMapAdd($DrvLtr2 & ":", "\\Server1\Share1\Shr2", 0, "nih\" & $UsrNm, $UsrPW) If $success2 Then MsgBox(4096,"Done", $DrvLtr2 & ": Drive mapped to \\Server1\Share1\Shr2") GuiCtrlSetData($Input_DrvLtr2, "") GuiCtrlSetState($Input_UsrNM, $GUI_FOCUS) ;start with cursor in this textbox GuiCtrlSetData($Input_UsrPW, "") Else MsgBox(4096,"Error", "Error mapping drive...") GuiCtrlSetState($Input_UsrNM, $GUI_FOCUS) ;start with cursor in this textbox EndIf EndIf RunAsSet();reset AutoIt's Run credentials EndSelect Wend Link to post Share on other sites
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