pcworldreader wrote:
.......so I think I'm going to find a program or script that will restart the service when it doesn't respond.... or find another service as a backup...
The easiest thing might be to install the free version of TeamViewer and use it to restart the remote computer. You can even restart it in the safe mode and have TeamViewer access. TeamViewer is a nice tool but they automatically flag certain accounts that they suspect are using it for commercial usage. (e.g. several computers connecting to the TeamViewer servers via one public facing IP = a business to them) If TeamViewer is not an option, then you might try this script:
#RequireAdmin
AutoItSetOption("TrayIconDebug", 1)
AutoItSetOption("WinWaitDelay", 1)
AutoItSetOption("WinTitleMatchMode", 3)
;just one copy of this tool should run at a time
$script_running = "keep-hamachi-alive"
If WinExists($script_running) Then Exit
AutoItWinSetTitle($script_running)
;this tool will uninstall and reinstall the hamachi service - if needed
;doing that will close the hamachi "window"
;A.K.A. the "Graphical User Interface" (GUI) or just "User Interface" (UI)
;so you need to decide if you want this tool to always start GUI
$always_start_GUI = "yes"
;changing the "yes" to "no" tells the tool to leave the GUI off if it had been off
;or to turn the GUI back on if it had been on before this tool killed it
;to hide all of the tray tips (ballons)
;remove ";" in front of the line below
;#NoTrayIcon
;but only do this after you turn off the debug tips in the next section
;with tray tips showing and debug times off,
;you should only see tray tips when the tool first starts
;this next part is mostly for me, but I suggest that you leave this "yes/no" alone
;until you have tested to see if this tool can make hamachi reconnect for you
$debug_tips = "yes"
$debug_time = "5000" ;determines how long you see the debug tray tips
If $debug_tips = "yes" Then TrayTip("$debug_tips =", "yes", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;read the registry to get the path to the these files
$path2ini = RegRead("HKLM\SOFTWARE\LogMeIn Hamachi", "EngineConfigDir") & "\h2-engine.ini"
;if reading the path info fails, just give up
If @error Then Exit
If $debug_tips = "yes" Then TrayTip("$path2ini = ", $path2ini, 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;if the file is not there, just give up
If Not FileExists($path2ini) Then
Exit
EndIf
;make a backup copy of the ini file
FileCopy($path2ini, RegRead("HKLM\SOFTWARE\LogMeIn Hamachi", "EngineConfigDir") & "\h2-engine.ini.tool.backup.copy", 1)
If $debug_tips = "yes" Then TrayTip("backing up the h2-engine.ini file", "we hope", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;if the file is not there, just give up
If Not FileExists(RegRead("HKLM\SOFTWARE\LogMeIn Hamachi", "EngineConfigDir") & "\h2-engine.ini.tool.backup.copy") Then
Exit
EndIf
$path2srv = RegRead("HKLM\SOFTWARE\LogMeIn Hamachi", "InstallDir") & "hamachi-2.exe"
If @error Then Exit
If $debug_tips = "yes" Then TrayTip("$path2srv = ", $path2srv, 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;if the file is not there, just give up
If Not FileExists($path2srv) Then
Exit
EndIf
$path2GUI = RegRead("HKLM\SOFTWARE\LogMeIn Hamachi", "InstallDir") & "hamachi-2-ui.exe"
If @error Then Exit
If $debug_tips = "yes" Then TrayTip("$path2GUI = ", $path2GUI, 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;if the file is not there, just give up
If Not FileExists($path2GUI) Then
Exit
EndIf
;this waits up to 5 minutes for the normal install of Hamachi to get the service going
For $i = 300 To 1 Step -1
If ProcessExists("hamachi-2.exe") Then
TrayTip("the hamachi service started", "surprised?", 100, 16)
Sleep(2000)
If $always_start_GUI = "yes" Then Run($path2GUI & " --auto-start")
ExitLoop
EndIf
TrayTip("waiting for the hamachi service to start", "moving on anyway in " & $i, 100, 16)
Sleep(1000)
Next
TrayTip("", "", 100)
While 1
;read the whole ini file
$s_ini = FileRead($path2ini)
If $debug_tips = "yes" Then TrayTip("reading ini file", "we hope", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;turn it into in separate lines
$s_ini_array = StringSplit($s_ini, @LF, 1)
If $debug_tips = "yes" Then TrayTip("parsing ini file", "we hope", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;read each line looking for the value of Reconnect
For $i = 1 To $s_ini_array[0] - 1
If StringInStr($s_ini_array[$i], "Reconnect") Then $reconnect = StringRight($s_ini_array[$i], 1)
Sleep(10)
Next
If $debug_tips = "yes" Then TrayTip("$reconnect = ", $reconnect, 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;if reconnect is 0 then the user turned hamachi off or hamachi barfed
;this was the issue I was facing - hamachi turned itself off at times
;perhaps a user told it to stop attempting to connect while the servers were busy
If $reconnect = "0" Then
;change the value of reconnect to 1
FileOpen($path2ini, 2)
For $i = 1 To $s_ini_array[0] - 1
If StringInStr($s_ini_array[$i], "Reconnect") Then
FileWrite($path2ini, "Reconnect 1" & @LF)
Else
FileWrite($path2ini, $s_ini_array[$i] & @LF)
EndIf
Sleep(10)
Next
FileClose($path2ini)
If $debug_tips = "yes" Then TrayTip("writing a reconnect value of 1 to the ini file", "we hope", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
EndIf
;check to see if the service is running
;it is possible to have the service die and the value of Reconnect still be 1
If $debug_tips = "yes" Then TrayTip("checking to see that the hamachi service is running", "we hope so", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
If $debug_tips = "yes" Then TrayTip("checking to see that hamachi is online", "we hope so", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
If Not ProcessExists("hamachi-2.exe") Or WinExists("LogMeIn Hamachi", "offline") Then
If $debug_tips = "yes" Then TrayTip("the hamachi service was not running or hamachi is offline", "bummer", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;check to see if the GUI is running
$GUI_was_running = "no"
If ProcessExists("hamachi-2-ui.exe") Then $GUI_was_running = "yes"
;if the service is not running - then there might be a problem with the service
;don't just start the service, recreate it
;uninstall the service - kills the GUI and set reconnect to 0 again
RunWait($path2srv & " -u", "", @SW_HIDE)
If $debug_tips = "yes" Then TrayTip("uninstalling the service", "we hope", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;uninstalling the service changes the value of reconnect to 0
;must change it back to 1 before reinstalling the service
FileOpen($path2ini, 2)
For $i = 1 To $s_ini_array[0] - 1
If StringInStr($s_ini_array[$i], "Reconnect") Then
FileWrite($path2ini, "Reconnect 1" & @LF)
Else
FileWrite($path2ini, $s_ini_array[$i] & @LF)
EndIf
Sleep(10)
Next
FileClose($path2ini)
If $debug_tips = "yes" Then TrayTip("writing a reconnect value of 1 to the ini file", "must do this after uninstalling the service", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;reinstall the service
Run($path2srv & " -i", "", @SW_HIDE)
If $debug_tips = "yes" Then TrayTip("reinstalling the service", "we hope", 100, 16)
If $debug_tips = "yes" Then Sleep($debug_time)
;start GUI - but only if it was running before this tool killed it
If $GUI_was_running = "yes" Then Run($path2GUI & " --auto-start")
EndIf
;always start the GUI if $always_start_GUI = "yes"
If Not ProcessExists("hamachi-2-ui.exe") And $always_start_GUI = "yes" Then Run($path2GUI & " --auto-start")
For $i = 60 To 1 Step -1
If $debug_tips = "yes" Then TrayTip("this tool will recheck hamachi in", $i, 100, 16)
Sleep(1000)
Next
WEnd
It works for me - but I'm on a simpler XP OS and I don't have the hung service issue to test adding a taskkill section to the script above. If you decide to use the script above, save the text into a file that ends in the ".au3" file extensions and install AutoIt from here:
http://www.autoitscript.com/site/autoit/downloads/ You can run the script as a text file from the start up folder or compile it into an EXE. Since I don't have a W7 system to test this on - I'm not sure what you would need to do to deal with the UAC.
You will need to read through the comments in the code and make your "yes/no" selections to make it run like you want. Also, if you decide to learn that scripting tool, there are prewritten sections of code that will let you determine and control the state of a service in a much more detailed way than the simple "if process is running" method that I used above. I did not include those methods because it would lengthen the script considerably.
The main two issues that I was attempting to solve with this script is:
the timing of the service vs the UI
(I removed the registry entry that starts the UI and use this script to start it)
someone of something would turn off the hamachi VPN via the GUI maybe
(I need it to always be on for several remote computers).
yucky forum software