markj Posted March 17, 2006 Share Posted March 17, 2006 To all those who can and do:I am creating a remote install console for software my customers use. The code is attached below. I have got to the bit where i want to copy selected directories to a remote pc but the directories will be different for each customer. There fore i need a new gui that will load where i can select the relevant customer and the program will then find that directory and copy it to the remote pc. The section of code is in redHOW DO I DO IT - it's twisting my melon man ; ----------------------------------------------------------------------------;; AutoIt Version: 3.1.1++;; Script Function: Control installation and de-installation of SolveSE; and Upgrade of SmartSwitch and SCSrv.; ;; ----------------------------------------------------------------------------#include <GuiConstants.au3>; Example global variablesGlobal $MainGuiMain() ; Call main function.ExitFunc Main() FileInstall("c:\AutoIT\SolCon\psservice.exe", @TempDir & "\psservice.exe") FileInstall("c:\AutoIT\SolCon\psexec.exe" , @TempDir & "\psexec.exe") $MainGui = GuiCreate("SolveSE Console", 296, 425, -1 , -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Label_1 = GuiCtrlCreateLabel("SolveSE Console: What do you want to do?", 40, 10, 270, 30) $Button_1 = GuiCtrlCreateButton("Stop SolveSE", 10, 40, 270, 30) $Button_2 = GuiCtrlCreateButton("Start SolveSE", 10, 80, 270, 30) $Button_3 = GuiCtrlCreateButton("Restart SolveSE", 10, 120, 270, 30) $Button_4 = GuiCtrlCreateButton("Upgrade SolveSE", 10, 170, 270, 40) $Button_5 = GuiCtrlCreateButton("Upgrade SmartSwitch", 10, 220, 270, 40) $Button_6 = GuiCtrlCreateButton("Upgrade SCSrv", 10, 270, 270, 40) $Button_6 = GuiCtrlCreateButton("Upgrade SilverFleet", 10, 320, 270, 40) $Button_7 = GuiCtrlCreateButton("Exit", 40, 370, 210, 20) $StatusBar = GuiCtrlCreateLabel("", 0, 407, 296, 18, BitOr($SS_SIMPLE, $SS_SUNKEN)) GUISetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_7 ExitLoop Case $msg = $Button_1 ; Stop SolveSE service StopSolveSE($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) Case $msg = $Button_2 ; Stop SolveSE service StartSolveSE($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) Case $msg = $Button_3 ; restart SolveSE service RStartSolveSE($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) Case $msg = $Button_5 ; Upgrade SmartSwitch UpgSmartSwitch($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) EndSelect WEnd FileDelete(@TempDir & "\pservice.exe") FileDelete(@TempDir & "\psexec.exe")EndFuncFunc StopSolveSE($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) Local $Computer = "", $Account = "", $Password = "" GuiCtrlSetState($Button_1, $GUI_DISABLE) GuiCtrlSetState($Button_2, $GUI_DISABLE) GuiCtrlSetState($Button_3, $GUI_DISABLE) If RemoteInfo($Computer, $Account, $Password) Then GUICtrlSetData($StatusBar, "-> Stopping SolveSE") $Ret = RunWait(@TempDir & "\psservice \\" & $Computer & " -u " & $Account & " -p " & $Password & " stop SolveSE", "", @SW_HIDE) ; Returns errorlevel of net stop command If $Ret <> 0 Then MsgBox(262144 + 16, "SolveSE", "Stopping the SolveSE service failed") GUICtrlSetData($StatusBar, "SolveSE Stop failed") Else GUICtrlSetData($StatusBar, "SolveSE Stopped") EndIf EndIf GuiCtrlSetState($Button_1, $GUI_ENABLE) GuiCtrlSetState($Button_2, $GUI_ENABLE) GuiCtrlSetState($Button_3, $GUI_ENABLE)EndFuncFunc StartSolveSE($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) Local $Computer, $Account, $Password GuiCtrlSetState($Button_1, $GUI_DISABLE) GuiCtrlSetState($Button_2, $GUI_DISABLE) GuiCtrlSetState($Button_3, $GUI_DISABLE) If RemoteInfo($Computer, $Account, $Password) Then GUICtrlSetData($StatusBar, "-> Starting SolveSE") $Ret = RunWait(@TempDir & "\psservice \\" & $Computer & " -u " & $Account & " -p " & $Password & " start SolveSE", "", @SW_HIDE) ; Returns errorlevel of net start command If $Ret <> 0 Then MsgBox(262144 + 16, "SolveSE", "Starting the SolveSE service failed") GUICtrlSetData($StatusBar, "SolveSE Start failed") Else GUICtrlSetData($StatusBar, "SolveSE Started") EndIf EndIf GuiCtrlSetState($Button_1, $GUI_ENABLE) GuiCtrlSetState($Button_2, $GUI_ENABLE) GuiCtrlSetState($Button_3, $GUI_ENABLE)EndFuncFunc RStartSolveSE($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) Local $Computer, $Account, $Password GuiCtrlSetState($Button_1, $GUI_DISABLE) GuiCtrlSetState($Button_2, $GUI_DISABLE) GuiCtrlSetState($Button_3, $GUI_DISABLE) If RemoteInfo($Computer, $Account, $Password) Then GUICtrlSetData($StatusBar, "-> Restarting SolveSE") $Ret = RunWait(@TempDir & "\psservice \\" & $Computer & " -u " & $Account & " -p " & $Password & " restart solvese", "", @SW_HIDE) ; Returns errorlevel of net start command If $Ret <> 0 Then MsgBox(262144 + 16, "SolveSE", "Restarting the SolveSE service failed") GUICtrlSetData($StatusBar, "SolveSE Restart failed") Else GUICtrlSetData($StatusBar, "SolveSE Restarted") EndIf EndIf GuiCtrlSetState($Button_1, $GUI_ENABLE) GuiCtrlSetState($Button_2, $GUI_ENABLE) GuiCtrlSetState($Button_3, $GUI_ENABLE)EndFunc;--------------Code to upgrade SmartSwitch on remote host will run from here---------------------------------------------------------------------------------------------Func UpgSmartSwitch($StatusBar, $Button_1, $Button_2, $Button_3, $Button_5) Local $Computer, $Account, $Password GuiCtrlSetState($Button_5, $GUI_DISABLE) If RemoteInfo($Computer, $Account, $Password) Then GUICtrlSetData($StatusBar, "-> Upgrading SmartSwitch") FileCopy("c:\AutoIT\SolCon\SmartUPG.exe" , @TempDir , 1) EndIf GuiCtrlSetState($Button_5, $GUI_ENABLE)EndFunc;--------------------------------------------------------------------------------------------------------------------------------------------------------------------Func RemoteInfo(ByRef $Computer, ByRef $Account, ByRef $Password) $iOk = 0 $Info = GuiCreate("Enter parameters", 200, 140, -1, -1, -1, $WS_EX_TOPMOST) GUICtrlCreateLabel("Computer name", 5, 8, 80, 20) $CompName = GUICtrlCreateInput("", 85, 5, 110, 20) GUICtrlCreateLabel("Account", 5, 38, 80, 20) $Login = GUICtrlCreateInput("Administrator", 85, 35, 110, 20) GUICtrlCreateLabel("Password", 5, 68, 80, 20) $Passwd = GUICtrlCreateInput("", 85, 65, 110, 20, $ES_PASSWORD) $btnOk = GUICtrlCreateButton("&Ok", 100, 100, 40, 30) $btnCancel = GUICtrlCreateButton("&Cancel", 150, 100, 40, 30) GuiSetState() While 1 $msg2 = GuiGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE Or $msg2 = $btnCancel ExitLoop Case $msg2 = $btnOk $Computer = GUICtrlRead($CompName) $Account = GUICtrlRead($Login) $Password = GUICtrlRead($Passwd) $iOk = 1 ExitLoop EndSelect WEnd GUISwitch($MainGui) GuiDelete($Info) Return $iOkEndFunc Link to comment Share on other sites More sharing options...
BigDod Posted March 17, 2006 Share Posted March 17, 2006 I do not have time to look through your code but from your description I think this might help $var = FileSelectFolder("Choose a folder.", "") MsgBox(0,"You chose", $var) Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
markj Posted March 17, 2006 Author Share Posted March 17, 2006 thanks - that worked a treat. 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