MichaelM Posted January 10, 2011 Share Posted January 10, 2011 Hi folks I created an application and I set it up as a service using the guidlines posted in the forums - there is a group of scripts called services.au3 Anyway the service is working fine it starts straightaway but when I go to stop it it does not stop I have to kill the process in order for it to stop. Is there something I need in the application to allow it to say a stop request has been made please exit. The script has a while loop in it that makes it loop every 2 minutes indefinitely - (the script is checking the status of the services on the box ironically) So is due to the while loop perhaps or am I just way off the mark. I am by no means a super programmer so go easy on me Michael Cheers Link to comment Share on other sites More sharing options...
spudw2k Posted January 10, 2011 Share Posted January 10, 2011 Just off the top of my head, It might not be stop if depending on how the 2 minute event you mentioned is coded. Also, how are you running it as a service? With a 3rd party tool or using the Service code demonstrated Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Kalin Posted January 10, 2011 Share Posted January 10, 2011 (edited) It would be easier to help if you posted your code here. Just saying. But @ your problem, the reason why this happens is because AutoIt scripts don't close by default until the loop is satisfied. In other words, you'll have to end the loop internally if you don't want this problem to occur externally. spudw2k, the UDF you posted is probably too complex for someone fairly new to AutoIt. Besides, I don't think that's the solution to his problem. o.o Edited January 10, 2011 by Kalin Link to comment Share on other sites More sharing options...
spudw2k Posted January 11, 2011 Share Posted January 11, 2011 (edited) spudw2k, the UDF you posted is probably too complex for someone fairly new to AutoIt. Besides, I don't think that's the solution to his problem. o.oI'd say the UDF would only make things too complex if you look at the backend code dealing with the SCM. It is a beast I admit, but there are very simple examples and it's definitely worth researching if the intention is to make an AutoIt Script that functions as a service.It would be easier to help if you posted your code here.Agreed Edited January 11, 2011 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
MichaelM Posted January 12, 2011 Author Share Posted January 12, 2011 HI spudw2k Yes I am using the UDF as described and the service does install and starts and functions correctly but I don't obviously have a provision for stopping. I have no problem posting code I have attached the file below. I don't think the loop method is the most efficient however within the scope of my knowledge it is the best I could do so any help on improving this script would be really appreciated. Cheers MIchaelServiceMonitoring.au3 Link to comment Share on other sites More sharing options...
spudw2k Posted January 12, 2011 Share Posted January 12, 2011 Just a couple of things. When I used the Service UDF, it would call the func Main, but I don't see that in your code. Not sure if that's causing the problem or if you changed the UDF on your machine. Anyways, here's what I recommend as far as the pause/sleep. Instead of doing a sleep, have a timer running and if that timer reaches the desired duration, run the main code and reset the timer. The sleep command more-or-less hangs the process from what I understand. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
MichaelM Posted January 13, 2011 Author Share Posted January 13, 2011 Hiya, Do you have any examples of using a timer function, never thought of that I have used them before in VB. I will check the Main() function I kind of figured this was just the way the example was coded. When the stop command is sent from the Service control manager I wonder is there anything you need in your code to react to, I was thinking if I am sleeping for 2 minutes and then just looping I am not looking for something asking me to shutdown - now might not be needed but just a thought. Link to comment Share on other sites More sharing options...
Varian Posted January 13, 2011 Share Posted January 13, 2011 Timer Function exampleFunc _Sleep($mSecsToSleep) Local $StartTimer $StartTimer = TimerInit() While 1 If TimerDiff($StartTimer) >= $mSecsToSleep Then Return Sleep(10) ;nominal sleep time to ease process consumption but maintain control of the System WEnd EndFunc Link to comment Share on other sites More sharing options...
Varian Posted January 13, 2011 Share Posted January 13, 2011 (edited) Can't delete accidental double post Edited January 13, 2011 by Varian Link to comment Share on other sites More sharing options...
MichaelM Posted January 17, 2011 Author Share Posted January 17, 2011 what is the benefit of using the timer versus sleep. also any further thoughts on how to get my app to respond to the stop command. Link to comment Share on other sites More sharing options...
MichaelM Posted January 17, 2011 Author Share Posted January 17, 2011 Hi folks, I noticed also that since I made the app a service it is no longer detecting that a service has stopped which is annoying.. Any thoughts as to why that is. Link to comment Share on other sites More sharing options...
MichaelM Posted January 20, 2011 Author Share Posted January 20, 2011 the trail goes cold I think.... 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