
leo8888
Active Members-
Posts
32 -
Joined
-
Last visited
leo8888's Achievements

Seeker (1/7)
0
Reputation
-
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Thank you for the link, I appreciate it! -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
I could but since this is a production server and some employees are working remotely I did not want to have to restart the server if I could help it. At least what I have now gives the desired result. I may go back eventually to my original scripts and test with DEP disabled. -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
After trying many different combinations of script commands and batch file commands I decided to take a new approach. I believe that the operating system (Server 2012 R2) is blocking the restart through DEP, at least that is my guess, and I did not want to have to disable DEP since everything else is working fine. Since the connector seemed like it would always restart on the second try if I used a separate script or batch file I decided to create two separate scripts. One to kill the connector and one to restart it. Then I changed the code on the workstations script to send the trigger files to both scripts, pause 20 seconds, then send the trigger file to just the restart script. I have tested several times from a workstation and it appears to work fine. Here are the updated scripts I came up with. They are messy but they work. Thank you all for your suggestions and ideas! Script to monitor for kill command: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=WebConnectorResetMonitor.exe #AutoIt3Wrapper_Outfile_x64=WebConnectorResetMonitor64.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <Constants.au3> #include <Array.au3> Opt ("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode local $MainGui = GuiCreate("Quickbooks Web Connector Reset Monitor",450,150) GUISetOnEvent($GUI_EVENT_CLOSE, "CancelButton") local $iCancelButton = GuiCtrlCreateButton("End Monitor",150,50,100,25) local $iLastReset = GUICtrlCreateLabel ( "Waiting for reset request...", 50, 100, 400, 25) local $iResetCount = 0 GUICtrlSetFont(-1, 12) GUICtrlSetOnEvent($iCancelButton, "CancelButton") GUISetState(@SW_SHOW, $MainGui) local $iRet = 0 While 1 Sleep(100) ; Sleep to reduce CPU usage If FileExists("e:\QuickBooks\ResetWebConnector.txt") Then ; Check for trigger file $iRet = Run("TaskKill /IM qbwc.exe /T /F") ConsoleWrite("TaskKill " & $iRet & "/" & @error & @CRLF) $iRet = ProcessWaitClose("qbwc.exe") ConsoleWrite("WaitClose " & $iRet & "/" & @error & @CRLF) $iResetCount = $iResetCount + 1 GUICtrlSetData( $iLastReset, "Last Reset: " & _Now() & " Count: " & $iResetCount ) FileDelete("e:\QuickBooks\ResetWebConnector.txt") ; Delete trigger file EndIf WEnd Func CancelButton() Exit EndFunc ;==>CancelButton GuiDelete($MainGui) Script to monitor for restart command: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=WebConnectorRestartMonitor.exe #AutoIt3Wrapper_Outfile_x64=WebConnectorRestartMonitor64.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <Constants.au3> Opt ("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode local $MainGui = GuiCreate("Quickbooks Web Connector Restart Monitor",450,150) GUISetOnEvent($GUI_EVENT_CLOSE, "CancelButton") local $iCancelButton = GuiCtrlCreateButton("End Monitor",150,50,100,25) local $iLastRestart = GUICtrlCreateLabel ( "Waiting for restart request...", 50, 100, 400, 25) GUICtrlSetFont(-1, 12) GUICtrlSetOnEvent($iCancelButton, "CancelButton") GUISetState(@SW_SHOW, $MainGui) local $iRet = 0 While 1 Sleep(100) ; Sleep to reduce CPU usage If FileExists("e:\QuickBooks\RestartWebConnector.txt") Then ; Check for trigger file Sleep(5000) $iRet = Run("C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe", "C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\") ConsoleWrite("Restart " & $iRet & "/" & @error & @CRLF) GUICtrlSetData( $iLastRestart, "Last Restart: " & _Now() ) FileDelete("e:\QuickBooks\RestartWebConnector.txt") ; Delete trigger file EndIf WEnd Func CancelButton() Exit EndFunc ;==>CancelButton GuiDelete($MainGui) Workstation script to send kill and reset trigger files to server: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Reset Web Connector.Exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode local $MainGui = GuiCreate("Reset Quickbooks Web Connector on PRS4",450,150) GUISetOnEvent($GUI_EVENT_CLOSE, "CancelButton") local $iResetButton = GuiCtrlCreateButton("Reset Connector",80,50,140,25) GUICtrlSetFont(-1, 12) GUICtrlSetOnEvent($iResetButton, "ResetButton") local $iCancelButton = GuiCtrlCreateButton("Cancel",275,50,80,25) GUICtrlSetFont(-1, 12) GUICtrlSetOnEvent($iCancelButton, "CancelButton") local $iResetWait = GUICtrlCreateLabel ( "Waiting for reset request...", 50, 100, 400, 25) GUISetState(@SW_SHOW, $MainGui) While 1 Sleep(100) ; Sleep to reduce CPU usage WEnd Func ResetButton() $tCur = _Date_Time_GetSystemTime() GUICtrlSetData( $iResetWait, "Resetting Web Connector, Please Wait... " ) ShellExecuteWait("cmd.exe", "/c echo $tCur > i:\ResetWebConnector.txt") ShellExecuteWait("cmd.exe", "/c echo $tCur > i:\RestartWebConnector.txt") Sleep(20000) ShellExecuteWait("cmd.exe", "/c echo $tCur > i:\RestartWebConnector.txt") Exit EndFunc ;==>ResetButton Func CancelButton() Exit EndFunc ;==>CancelButton GuiDelete($MainGui) -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Tried to cleanup and shorten the code and implement the suggestion: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=WebConnectorResetMonitor.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <Constants.au3> #include <Array.au3> Opt ("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode local $MainGui = GuiCreate("Quickbooks Web Connector Reset Monitor",450,150) GUISetOnEvent($GUI_EVENT_CLOSE, "CancelButton") local $iCancelButton = GuiCtrlCreateButton("End Monitor",150,50,100,25) local $iLastReset = GUICtrlCreateLabel ( "Waiting for reset request...", 50, 100, 400, 25) local $iResetCount = 0 GUICtrlSetFont(-1, 12) GUICtrlSetOnEvent($iCancelButton, "CancelButton") GUISetState(@SW_SHOW, $MainGui) local $iRet = 0 While 1 Sleep(100) ; Sleep to reduce CPU usage If FileExists("e:\QuickBooks\ResetWebConnector.txt") Then ; Check for trigger file $iRet = Run("TaskKill /IM qbwc.exe /T /F") ConsoleWrite("TaskKill " & $iRet & "/" & @error & @CRLF) $iRet = ProcessWaitClose("qbwc.exe") ConsoleWrite("WaitClose " & $iRet & "/" & @error & @CRLF) $iRet = Run(@AutoItExe & ' /AutoIt3ExecuteLine "Run(''C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe'',''C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\'')"') ConsoleWrite("AutoIT Run " & $iRet & "/" & @error & @CRLF) $iResetCount = $iResetCount + 1 GUICtrlSetData($iLastReset, "Last Reset: " & _Now() & " Count: " & $iResetCount) FileDelete("e:\QuickBooks\ResetWebConnector.txt") ; Delete trigger file Sleep(2000) EndIf WEnd Func CancelButton() Exit EndFunc ;==>CancelButton GuiDelete($MainGui) >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Administrator\Desktop\Command Scripts\WebConnectorResetBak2.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. TaskKill 20824/0 WaitClose 1/0 AutoIT Run 24904/0 Still the same result. Everything SHOULD work but the process just will not restart. If I run the single command to start the process in a different script it works fine. -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
I like this idea. I'll give it a try. Thank you. -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Yes, I can use that from a command prompt and the batch file with always start it on the second run but not the first. -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Yes, I was trying that last week before I left work. The Script would just hang indefinitely waiting for the process to start, even with a very long sleep (over 5 minutes) or multiple start lines separated by sleeps. I watched task manager and would sometimes see the qbwc.exe process start for a split second but disappear. -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
So I have verified that AutoIT is definitely not the issue. I created a simple batch to kill and restart the qbwc.exe and it also only works as a "toggle". If I run it the first time it will kill the web connector but not restart it. The second time it will restart the connector. It seems the OS is not allowing one single process to kill and restart the qbwc.exe. I wanted to thank everyone for their time and suggestions! @echo off TaskKill /IM qbwc.exe /T /F pause start C:\"Program Files (x86)"\ServiceTitan\"ServiceTitan QBWC"\QBWC.exe -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Thank you Jocko. The option to turn logging on or off are not present when I right click the connector on the systray. Service Titan may have removed that option I am guessing. I even tried a ridiculously long wait delay of 6 minutes before the script restarted the connector but it still did not work. Strange thing is I can still manually restart it immediately from outside the script. -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
I must have read your thoughts because I already tried that. The batch works fine but when I call it from the script I get the same result as every other command I have tried to run it. I am beginning to wonder if the OS is somehow blocking the execution. Maybe DEP is coming into play. I would have to disable it and reboot the server to test. -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Sorry, I forgot to mention that I added that to the code already: $iPID = Run("C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe", "C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC") -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
As suggested by Jocko I searched for any files being updated in the service titan directory but there are none. When the web connector is running is has it's own log window but I cannot find a log of it outside of that. The shortcut has the same working directory as the program and I verified in task manager that the qbwc.exe is 32bit. I am testing from the console logged in as administrator. As a test I tried just putting the run line by itself in a separate script and if I break out of the first script and run the second the qbwc.exe will start. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=WebConnectorResetMonitor.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> Run("C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe") ; Restart the Service Titan Web Connector -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
I have that log file but it is only for the original version of the web connector that was supplied with quickbooks and has not been updated for months. The web connector we use now was supplied by another vendor, service titan. I may ask them if there is a log file being generated somewhere under a different name. I tried adding the full path to the command as Nine suggested but still no luck. I am thinking that this may not be something I can accomplish with AutoIT. Sometimes things that should be simple turn out more complex than anticipated. I think this may be one of those times. I really appreciate the time everyone has spent trying to find the issue with my code. I have learned a great deal just from the suggestions provided! -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Updated code and all output. Notice the second array comes up blank. The ConsoleWrite output shows the qbwc.exe process is starting ok but it seems like it immediately disappears? #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=WebConnectorResetMonitor.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <Constants.au3> #include <Array.au3> Opt ("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode local $MainGui = GuiCreate("Quickbooks Web Connector Reset Monitor",450,150) GUISetOnEvent($GUI_EVENT_CLOSE, "CancelButton") local $iCancelButton = GuiCtrlCreateButton("End Monitor",150,50,100,25) local $iLastReset = GUICtrlCreateLabel ( "Waiting for reset request...", 50, 100, 400, 25) local $iResetCount = 0 GUICtrlSetFont(-1, 12) GUICtrlSetOnEvent($iCancelButton, "CancelButton") GUISetState(@SW_SHOW, $MainGui) local $iRet = 0 local $iPID = 0 local $aList = 0 While 1 Sleep(100) ; Sleep to reduce CPU usage If FileExists("e:\QuickBooks\ResetWebConnector.txt") Then ; Check for trigger file Local $aList = ProcessList ("qbwc.exe") _ArrayDisplay($aList) $iRet = Run("TaskKill /IM qbwc.exe /T /F") ConsoleWrite("TaskKill " & $iRet & "/" & @error & @CRLF) $iRet = ProcessWaitClose("qbwc.exe") ConsoleWrite("WaitClose " & $iRet & "/" & @error & @CRLF) $iPID = Run("C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe") ConsoleWrite("Run " & $iPID & "/" & @error & @CRLF) $iRet = ProcessWait($iPID) Local $aList = ProcessList ("qbwc.exe") _ArrayDisplay($aList) ConsoleWrite("Wait " & $iRet & "/" & @error & @CRLF) $iResetCount = $iResetCount + 1 GUICtrlSetData($iLastReset, "Last Reset: " & _Now() & " Count: " & $iResetCount) FileDelete("e:\QuickBooks\ResetWebConnector.txt") ; Delete trigger file Sleep(2000) EndIf WEnd Func CancelButton() Exit EndFunc ;==>CancelButton GuiDelete($MainGui) TaskKill 17056/0 WaitClose 1/0 Run 23176/0 Wait 23176/0 -
only one program will run inside if then
leo8888 replied to leo8888's topic in AutoIt General Help and Support
Updated the code as suggested. Array display output and ConsoleWrite output included below. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=WebConnectorResetMonitor.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Date.au3> #include <Constants.au3> #include <Array.au3> Opt ("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode local $MainGui = GuiCreate("Quickbooks Web Connector Reset Monitor",450,150) GUISetOnEvent($GUI_EVENT_CLOSE, "CancelButton") local $iCancelButton = GuiCtrlCreateButton("End Monitor",150,50,100,25) local $iLastReset = GUICtrlCreateLabel ( "Waiting for reset request...", 50, 100, 400, 25) local $iResetCount = 0 GUICtrlSetFont(-1, 12) GUICtrlSetOnEvent($iCancelButton, "CancelButton") GUISetState(@SW_SHOW, $MainGui) local $iRet = 0 local $iPID = 0 local $aList = 0 While 1 Sleep(100) ; Sleep to reduce CPU usage If FileExists("e:\QuickBooks\ResetWebConnector.txt") Then ; Check for trigger file Local $aList = ProcessList ("qbwc.exe") _ArrayDisplay($aList) $iRet = Run("TaskKill /IM qbwc.exe /T /F") ConsoleWrite("TaskKill " & $iRet & "/" & @error & @CRLF) $iRet = ProcessWaitClose("qbwc.exe") ConsoleWrite("WaitClose " & $iRet & "/" & @error & @CRLF) $iPID = Run("C:\Program Files (x86)\ServiceTitan\ServiceTitan QBWC\QBWC.exe") ConsoleWrite("Run " & $iPID & "/" & @error & @CRLF) $iRet = ProcessWait($iPID) ConsoleWrite("Wait " & $iRet & "/" & @error & @CRLF) $iResetCount = $iResetCount + 1 GUICtrlSetData($iLastReset, "Last Reset: " & _Now() & " Count: " & $iResetCount) FileDelete("e:\QuickBooks\ResetWebConnector.txt") ; Delete trigger file EndIf WEnd Func CancelButton() Exit EndFunc ;==>CancelButton GuiDelete($MainGui) ConsoleWrite output: TaskKill 11716/0 WaitClose 1/0 Run 22192/0 Wait 22192/0