Author: Zero3
Date: 2009-01-23 14:38:20 +0000 (Fri, 23 Jan 2009)
New Revision: 25239

Modified:
   trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk
   trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk
Log:
Only try to start/stop service once to avoid UAC popup hell if user changes his 
mind

Modified: trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk
===================================================================
--- trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk 2009-01-23 
14:34:07 UTC (rev 25238)
+++ trunk/apps/wininstaller/src_freenethelpers/FreenetStart.ahk 2009-01-23 
14:38:20 UTC (rev 25239)
@@ -43,6 +43,7 @@
 
 FileReadLine, _InstallSuffix, installid.dat, 1
 _ServiceName = freenet%_InstallSuffix%
+_ServiceHasBeenStarted := 0                                    ; Used to make 
sure that we only start the service once (to avoid UAC spam on Vista, among 
other things)
 
 Loop
 {
@@ -65,23 +66,31 @@
        }
        Else If (_ServiceState == 1 || _ServiceState == 7)
        {
-               _ReturnCode := Service_Start(_ServiceName)
-               If (_ReturnCode <> 1)
+               If (!_ServiceHasBeenStarted)
                {
-                       PopupErrorMessage("Freenet start script was unable to 
start the Freenet system service.`n`nPlease reinstall Freenet.`n`nIf the 
problem keeps occurring, please report this error message to the developers.")
-                       ExitApp, 1
+                       _ServiceHasBeenStarted := 1
+                       Service_Start(_ServiceName)
                }
                Else
                {
-                       ExitApp, 0
+                       PopupErrorMessage("Freenet start script was unable to 
start the Freenet system service.`n`nPlease reinstall Freenet.`n`nIf the 
problem keeps occurring, please report this error message to the developers.")
+                       ExitApp, 1
                }
        }
        Else
        {
-               ExitApp, 2                                      ; Service must 
be running then!
+               If (_ServiceHasBeenStarted)
+               {
+                       ExitApp, 0                              ; 0 = We 
started it
+               }
+               Else
+               {
+                       ExitApp, 2                              ; 2 = No action 
taken (service was already running)
+               }
        }
 }
 
+
 ;
 ; Helper functions
 ;

Modified: trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk
===================================================================
--- trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk  2009-01-23 
14:34:07 UTC (rev 25238)
+++ trunk/apps/wininstaller/src_freenethelpers/FreenetStop.ahk  2009-01-23 
14:38:20 UTC (rev 25239)
@@ -43,6 +43,7 @@
 
 FileReadLine, _InstallSuffix, installid.dat, 1
 _ServiceName = freenet%_InstallSuffix%
+_ServiceHasBeenStopped := 0                                    ; Used to make 
sure that we only stop the service once (to avoid UAC spam on Vista, among 
other things)
 
 Loop
 {
@@ -65,20 +66,26 @@
        }
        Else If (_ServiceState == 1)
        {
-
-               ExitApp, 2                                              ; 
Service must be stopped then!
+               If (_ServiceHasBeenStopped)
+               {
+                       ExitApp, 0                              ; 0 = We 
stopped it
+               }
+               Else
+               {
+                       ExitApp, 2                              ; 2 = No action 
taken (service was already stopped)
+               }
        }
        Else
        {
-               _ReturnCode := Service_Stop(_ServiceName)
-               If (_ReturnCode <> 1)
+               If (!_ServiceHasBeenStopped)
                {
-                       PopupErrorMessage("Freenet stop script was unable to 
stop the Freenet system service.`n`nPlease reinstall Freenet.`n`nIf the problem 
keeps occurring, please report this error message to the developers.")
-                       ExitApp, 1
+                       _ServiceHasBeenStopped := 1
+                       Service_Stop(_ServiceName)
                }
                Else
                {
-                       ExitApp, 0
+                       PopupErrorMessage("Freenet stop script was unable to 
stop the Freenet system service.`n`nPlease reinstall Freenet.`n`nIf the problem 
keeps occurring, please report this error message to the developers.")
+                       ExitApp, 1
                }
        }
 }

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to