Sign in to follow this  
Followers 0
markj

Directory Selection Gui

3 posts in this topic

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 red

HOW 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 variables

Global $MainGui

Main() ; Call main function.

Exit

Func 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")

EndFunc

Func 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)

EndFunc

Func 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)

EndFunc

Func 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 $iOk

EndFunc

Share this post


Link to post
Share on other sites



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)


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

thanks - that worked a treat.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0