lansti Posted May 9, 2011 Posted May 9, 2011 Hi, i have scripted a little program that should help my users to connect to different networkshares with they domain user/password from a local user account. But since i have several shares they can choose between, i want this script as a function... but i'm not so familiar with that. Can someone help me out? case $msg = $networkshare1 $ES_PASSWORD = 0x0020 GUICreate("Logg inn", 230,100) GUICtrlCreateLabel("Username:",5,15) GUICtrlCreateLabel("Password:",5,40) $domainUser = GUICtrlCreateInput("",65,15,160,17) $domainpassword = GUICtrlCreateInput("",65,40,160,17,$ES_PASSWORD) $Login = GUICtrlCreateButton("Logg på",5,65,190) GUISetState() while 1 $msg = GUIGetMsg() Select Case $msg = $Login _RunDOS("net use z: /delete /yes > nul") _RunDOS("net use z: \\server.domain.com\path " & GUICtrlRead($domainpassword) & " /USER:domain\" & GUICtrlRead($domainUser)) MsgBox(64,$MsgTitle, "Kobler til z:\networkshare1 ",2) GUISetState(@SW_HIDE) Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd
hannes08 Posted May 9, 2011 Posted May 9, 2011 (edited) Hi lansti, you could use one GUI and display a radio-button group where your users can choose the network share. Then when you the $login button has been pressed, you could check for the state of the radio-buttons. Check the helpfile for GUICtrlCreateRadio on how to create a radio-button (group). You could create a function called _mapShare($share, $user, $password, $driveletter) Func _mapShare($share, $user, $password, $driveletter) DriveMapDel($driveletter) DriveMapAdd($driveletter,$share,0,$user,$password) EndFunc Edited May 9, 2011 by Hannes123 Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
enaiman Posted May 9, 2011 Posted May 9, 2011 An alternative to Hannes123 solution: you can always use a combobox to let the users select from the list. Radio button OR Combobox = works for only 1 element at a time. If you want the users to get acces to more than one share with a button press - consider using checkboxes for every share. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
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