botanic Posted January 1, 2010 Share Posted January 1, 2010 I want to kill svn.exe gracefully when a button is clicked however ControlSend("C:\Program Files (x86)\Subversion\bin\svn.exe","",$foo,"^c") does not seem to work since the window is hidden. Anyone have any ideas? Here is the code: expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=MattL.ico #AutoIt3Wrapper_outfile=updatesvn.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Example1() ; example 1 Func Example1() Local $msg , $drive, $gui GUICreate("Ubiquity USB Update Tool",160,115) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $Button_1 = GUICtrlCreateButton("Install Subversion", 5, 5,150,50) $Button_2 = GUICtrlCreateButton("Update USB", 5, 60,150,50) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 FileInstall("C:\development\USB\SetupUSB\setup.msi",@TempDir&"\setup.msi") ShellExecuteWait(@TempDir&"\setup.msi") FileDelete(@TempDir&"\setup.msi") Case $msg = $Button_2 $drive = "NULL" if (DriveGetLabel("A:\") = "BOOTUSB") then $drive = "A:\" if (DriveGetLabel("B:\") = "BOOTUSB") then $drive = "B:\" if (DriveGetLabel("C:\") = "BOOTUSB") then $drive = "C:\" if (DriveGetLabel("D:\") = "BOOTUSB") then $drive = "D:\" if (DriveGetLabel("E:\") = "BOOTUSB") then $drive = "E:\" if (DriveGetLabel("F:\") = "BOOTUSB") then $drive = "F:\" if (DriveGetLabel("G:\") = "BOOTUSB") then $drive = "G:\" if (DriveGetLabel("H:\") = "BOOTUSB") then $drive = "H:\" if (DriveGetLabel("I:\") = "BOOTUSB") then $drive = "I:\" if (DriveGetLabel("J:\") = "BOOTUSB") then $drive = "J:\" if (DriveGetLabel("K:\") = "BOOTUSB") then $drive = "K:\" if (DriveGetLabel("L:\") = "BOOTUSB") then $drive = "L:\" if (DriveGetLabel("M:\") = "BOOTUSB") then $drive = "M:\" if (DriveGetLabel("N:\") = "BOOTUSB") then $drive = "N:\" if (DriveGetLabel("O:\") = "BOOTUSB") then $drive = "O:\" if (DriveGetLabel("P:\") = "BOOTUSB") then $drive = "P:\" if (DriveGetLabel("Q:\") = "BOOTUSB") then $drive = "Q:\" if (DriveGetLabel("R:\") = "BOOTUSB") then $drive = "R:\" if (DriveGetLabel("S:\") = "BOOTUSB") then $drive = "S:\" if (DriveGetLabel("T:\") = "BOOTUSB") then $drive = "T:\" if (DriveGetLabel("U:\") = "BOOTUSB") then $drive = "U:\" if (DriveGetLabel("V:\") = "BOOTUSB") then $drive = "V:\" if (DriveGetLabel("W:\") = "BOOTUSB") then $drive = "W:\" if (DriveGetLabel("X:\") = "BOOTUSB") then $drive = "X:\" if (DriveGetLabel("Y:\") = "BOOTUSB") then $drive = "Y:\" if (DriveGetLabel("Z:\") = "BOOTUSB") then $drive = "Z:\" ;"C:\Program Files (x86)\Subversion\bin\svn.exe" checkout= --username=asdf --password=xsd http://216.6.227.163/repos/mytestproj C:\SVN if $drive <> "NULL" Then if FileExists(@HomeDrive &"\Program Files (x86)\Subversion\bin\svn.exe") = True Then $foo = Run("""" & @HomeDrive &"\Program Files (x86)\Subversion\bin\svn.exe"" checkout --username=asdf --password=asdf http://216.6.227.163/repos/mytestproj "&$drive, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $gui = GUICreate("My GUI", 510, 535) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $button = GUICtrlCreateButton("Exit", 5,510,50,20) $myedit = GUICtrlCreateEdit("'Running svn.exe'..." & @CRLF, 5, 5, 500, 500, $ES_AUTOVSCROLL + $WS_VSCROLL) ; Run the GUI until the dialog is closed While 1 $gui = GUIGetMsg() $text = StdoutRead($foo) GUICtrlSetData($myedit, $text, 1) $text = StderrRead($foo) GUICtrlSetData($myedit, $text, 1) If $gui = $GUI_EVENT_CLOSE Then ExitLoop if $gui = $button Then ControlSend("C:\Program Files (x86)\Subversion\bin\svn.exe","",$foo,"^c") GUICtrlSetData($myedit, "Exiting SVN.exe please wait...", 1) ProcessWaitClose($foo) ExitLoop EndIf WEnd GUIDelete() ElseIf FileExists("""" & @HomeDrive &"\Program Files\Subversion\bin\svn.exe") = True then $foo = Run("""" & @HomeDrive &"\Program Files (\Subversion\bin\svn.exe"" checkout --username=asdf --password=asdf http://216.6.227.163/repos/mytestproj "&$drive, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $gui = GUICreate("My GUI", 510, 510) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $myedit = GUICtrlCreateEdit("'Running svn.exe'..." & @CRLF, 5, 5, 500, 500, $ES_AUTOVSCROLL + $WS_VSCROLL) ; Run the GUI until the dialog is closed While 1 $gui = GUIGetMsg() $text = StderrRead($foo) GUICtrlSetData($myedit, $text, 1) If $gui = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Else MsgBox(0,"OPPS!", "Seems you did not install SVN yet, please install svn to the default location.") EndIf EndIf if $drive = "NULL" then MsgBox(0,"OPPS!", "Please insert the USB") EndSelect WEnd GUIDelete() EndFunc ;==>Example1 i tried stdin but couldnt get it to work... Link to comment Share on other sites More sharing options...
Remo1075 Posted January 1, 2010 Share Posted January 1, 2010 (edited) I want to kill svn.exe gracefully when a button is clicked however ControlSend("C:\Program Files (x86)\Subversion\bin\svn.exe","",$foo,"^c") does not seem to work since the window is hidden. Anyone have any ideas? Here is the code: expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=MattL.ico #AutoIt3Wrapper_outfile=updatesvn.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Example1() ; example 1 Func Example1() Local $msg , $drive, $gui GUICreate("Ubiquity USB Update Tool",160,115) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $Button_1 = GUICtrlCreateButton("Install Subversion", 5, 5,150,50) $Button_2 = GUICtrlCreateButton("Update USB", 5, 60,150,50) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 FileInstall("C:\development\USB\SetupUSB\setup.msi",@TempDir&"\setup.msi") ShellExecuteWait(@TempDir&"\setup.msi") FileDelete(@TempDir&"\setup.msi") Case $msg = $Button_2 $drive = "NULL" if (DriveGetLabel("A:\") = "BOOTUSB") then $drive = "A:\" if (DriveGetLabel("B:\") = "BOOTUSB") then $drive = "B:\" if (DriveGetLabel("C:\") = "BOOTUSB") then $drive = "C:\" if (DriveGetLabel("D:\") = "BOOTUSB") then $drive = "D:\" if (DriveGetLabel("E:\") = "BOOTUSB") then $drive = "E:\" if (DriveGetLabel("F:\") = "BOOTUSB") then $drive = "F:\" if (DriveGetLabel("G:\") = "BOOTUSB") then $drive = "G:\" if (DriveGetLabel("H:\") = "BOOTUSB") then $drive = "H:\" if (DriveGetLabel("I:\") = "BOOTUSB") then $drive = "I:\" if (DriveGetLabel("J:\") = "BOOTUSB") then $drive = "J:\" if (DriveGetLabel("K:\") = "BOOTUSB") then $drive = "K:\" if (DriveGetLabel("L:\") = "BOOTUSB") then $drive = "L:\" if (DriveGetLabel("M:\") = "BOOTUSB") then $drive = "M:\" if (DriveGetLabel("N:\") = "BOOTUSB") then $drive = "N:\" if (DriveGetLabel("O:\") = "BOOTUSB") then $drive = "O:\" if (DriveGetLabel("P:\") = "BOOTUSB") then $drive = "P:\" if (DriveGetLabel("Q:\") = "BOOTUSB") then $drive = "Q:\" if (DriveGetLabel("R:\") = "BOOTUSB") then $drive = "R:\" if (DriveGetLabel("S:\") = "BOOTUSB") then $drive = "S:\" if (DriveGetLabel("T:\") = "BOOTUSB") then $drive = "T:\" if (DriveGetLabel("U:\") = "BOOTUSB") then $drive = "U:\" if (DriveGetLabel("V:\") = "BOOTUSB") then $drive = "V:\" if (DriveGetLabel("W:\") = "BOOTUSB") then $drive = "W:\" if (DriveGetLabel("X:\") = "BOOTUSB") then $drive = "X:\" if (DriveGetLabel("Y:\") = "BOOTUSB") then $drive = "Y:\" if (DriveGetLabel("Z:\") = "BOOTUSB") then $drive = "Z:\" ;"C:\Program Files (x86)\Subversion\bin\svn.exe" checkout= --username=asdf --password=xsd http://216.6.227.163/repos/mytestproj C:\SVN if $drive <> "NULL" Then if FileExists(@HomeDrive &"\Program Files (x86)\Subversion\bin\svn.exe") = True Then $foo = Run("""" & @HomeDrive &"\Program Files (x86)\Subversion\bin\svn.exe"" checkout --username=asdf --password=asdf http://216.6.227.163/repos/mytestproj "&$drive, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $gui = GUICreate("My GUI", 510, 535) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $button = GUICtrlCreateButton("Exit", 5,510,50,20) $myedit = GUICtrlCreateEdit("'Running svn.exe'..." & @CRLF, 5, 5, 500, 500, $ES_AUTOVSCROLL + $WS_VSCROLL) ; Run the GUI until the dialog is closed While 1 $gui = GUIGetMsg() $text = StdoutRead($foo) GUICtrlSetData($myedit, $text, 1) $text = StderrRead($foo) GUICtrlSetData($myedit, $text, 1) If $gui = $GUI_EVENT_CLOSE Then ExitLoop if $gui = $button Then ControlSend("C:\Program Files (x86)\Subversion\bin\svn.exe","",$foo,"^c") GUICtrlSetData($myedit, "Exiting SVN.exe please wait...", 1) ProcessWaitClose($foo) ExitLoop EndIf WEnd GUIDelete() ElseIf FileExists("""" & @HomeDrive &"\Program Files\Subversion\bin\svn.exe") = True then $foo = Run("""" & @HomeDrive &"\Program Files (\Subversion\bin\svn.exe"" checkout --username=asdf --password=asdf http://216.6.227.163/repos/mytestproj "&$drive, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $gui = GUICreate("My GUI", 510, 510) ; will create a dialog box that when displayed is centered GUISetState(@SW_SHOW) ; will display an empty dialog box $myedit = GUICtrlCreateEdit("'Running svn.exe'..." & @CRLF, 5, 5, 500, 500, $ES_AUTOVSCROLL + $WS_VSCROLL) ; Run the GUI until the dialog is closed While 1 $gui = GUIGetMsg() $text = StderrRead($foo) GUICtrlSetData($myedit, $text, 1) If $gui = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Else MsgBox(0,"OPPS!", "Seems you did not install SVN yet, please install svn to the default location.") EndIf EndIf if $drive = "NULL" then MsgBox(0,"OPPS!", "Please insert the USB") EndSelect WEnd GUIDelete() EndFunc ;==>Example1 i tried stdin but couldnt get it to work... try this While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Run(@ComSpec & " /c " & 'appname.exe c:\*.* -s', "") Case $msg = $Button_2 Run(@ComSpec & " /c " & 'app2name.exe d:\*.* -s', "") Case $msg = $Button_3 Run(@ComSpec & " /c " & 'taskkill /F /IM app.exe', "",@SW_HIDE) EndSelect WEnd Edited January 1, 2010 by Remo1075 Link to comment Share on other sites More sharing options...
botanic Posted January 1, 2010 Author Share Posted January 1, 2010 (edited) doesn't work =/ tried it with and without the *32 also I dont think taskkill will cause it to exit gracefully and finish any I/O in progress, whereas ctrl+c does While 1 $gui = GUIGetMsg() $text = StdoutRead($foo) GUICtrlSetData($myedit, $text, 1) $text = StderrRead($foo) GUICtrlSetData($myedit, $text, 1) if $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $Button_1 Run(@ComSpec & " /c " & 'svn.exe *32 c:\*.* -s', "") Case $msg = $Button_2 Run(@ComSpec & " /c " & 'svn.exe *32 d:\*.* -s', "") Case $msg = $Button_3 Run(@ComSpec & " /c " & 'taskkill /F /IM svn.exe *32', "",@SW_HIDE) EndSelect WEnd Edited January 1, 2010 by botanic Link to comment Share on other sites More sharing options...
Remo1075 Posted January 1, 2010 Share Posted January 1, 2010 doesn't work =/ tried it with and without the *32 While 1 $gui = GUIGetMsg() $text = StdoutRead($foo) GUICtrlSetData($myedit, $text, 1) $text = StderrRead($foo) GUICtrlSetData($myedit, $text, 1) if $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $Button_1 Run(@ComSpec & " /c " & 'svn.exe *32 c:\*.* -s', "") Case $msg = $Button_2 Run(@ComSpec & " /c " & 'svn.exe *32 d:\*.* -s', "") Case $msg = $Button_3 Run(@ComSpec & " /c " & 'taskkill /F /IM svn.exe *32', "",@SW_HIDE) EndSelect WEnd you need to get rid of the switches I left in by mistake, as your program won't understand them While 1 $gui = GUIGetMsg() $text = StdoutRead($foo) GUICtrlSetData($myedit, $text, 1) $text = StderrRead($foo) GUICtrlSetData($myedit, $text, 1) if $msg = $GUI_EVENT_CLOSE Then ExitLoop Select Case $msg = $Button_1 Run(@ComSpec & " /c " & 'svn.exe', "") Case $msg = $Button_2 Run(@ComSpec & " /c " & 'anotherapp.exe', "") Case $msg = $Button_3 Run(@ComSpec & " /c " & 'taskkill /F /IM svn.exe', "",@SW_HIDE) EndSelect debug it by removing the ,@sw_hide and the change the c for a k in the kill line Link to comment Share on other sites More sharing options...
botanic Posted January 1, 2010 Author Share Posted January 1, 2010 ok well it did kill it however it terminated it and not gracefuly corrupting my checkout =/ any ideas on a graceful exit? Link to comment Share on other sites More sharing options...
Remo1075 Posted January 1, 2010 Share Posted January 1, 2010 Try not using the /F and see if it terminates gracefully. 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