MePHiTiC Posted October 25, 2011 Share Posted October 25, 2011 I'm trying to add a service to Windows Server 2003 Standard which basically runs another script every couple of mins. I've read through the various articles here and in the FAQ wiki on how to add a service to windows. I've tried the UDF's, the RunAsSvc application, the sc.exe application, and the srvany.exe application. While all of these add a service which I can get to start/stop, the script does nothing. Double clicking the service exe does what I expect. Below is the code I've basically stripped it down to opening notepad from a loop, this does nothing as a service, but does when double clicked. What am I missing? #Region #AutoIt3Wrapper_UseUpx=n #EndRegion While 1 ShellExecute("notepad.exe") Sleep(5000) WEnd Link to comment Share on other sites More sharing options...
BrewManNH Posted October 25, 2011 Share Posted October 25, 2011 Are you sure it's not doing anything? I would look in the TaskManager when the service is running to see if Notepad is running or not. It might be running it, but the window isn't visible to you. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
lgvlgv Posted October 25, 2011 Share Posted October 25, 2011 do u have UAC enabled? are u administrator? i would do what they allways tell me here, show us the code in this case how u create the service and check what BrewManNH says.. Link to comment Share on other sites More sharing options...
MePHiTiC Posted October 25, 2011 Author Share Posted October 25, 2011 Nothing is running in TaskManager (the script or in this case notepad.exe) and the service appears to be running without errors (logged to EventViewer). As for the code, right now I'm just trying to get the above code to run as a service. Every 5 seconds a new Notepad instance should be opened (or atleast I believe that's what should happen). I drilled down to this basic script just to see if the script I had as a service was doing anything, even with this nothing is happening. Link to comment Share on other sites More sharing options...
MePHiTiC Posted October 25, 2011 Author Share Posted October 25, 2011 do u have UAC enabled?are u administrator? i would do what they allways tell me here, show us the code in this case how u create the service and check what BrewManNH says.. I don't believe Windows Server 2003 Standard has UAC, or does it? I'm not getting prompts when I run it just by double clicking on it. I have tried running this as admin as a service, no go. Double clicking it as admin works as I expect. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 25, 2011 Share Posted October 25, 2011 When you're looking in Task Manager are you viewing programs run by all users? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Skitty Posted October 25, 2011 Share Posted October 25, 2011 I don't believe Windows Server 2003 Standard has UAC, or does it? I'm not getting prompts when I run it just by double clicking on it. I have tried running this as admin as a service, no go. Double clicking it as admin works as I expect. I remember people saying you have to create the service with the option "Interact with desktop" or something like that, working with services is tricky, I have yet to see an example that can run as a service and create files on the desktop (or anywhere else), show gui's and almost anything else. But then again, I'm new to this... Link to comment Share on other sites More sharing options...
MePHiTiC Posted October 25, 2011 Author Share Posted October 25, 2011 When you're looking in Task Manager are you viewing programs run by all users? Yeah made sure I was seeing all tasks. I'll double check again tomorrow to be sure however. Link to comment Share on other sites More sharing options...
MePHiTiC Posted October 25, 2011 Author Share Posted October 25, 2011 I remember people saying you have to create the service with the option "Interact with desktop" or something like that, working with services is tricky, I have yet to see an example that can run as a service and create files on the desktop (or anywhere else), show gui's and almost anything else. But then again, I'm new to this... I seen reference to this as well. I checked the interactive check box on the service which also didn't appear to do anything. From everything I've done the best I can tell is any of my scripts set as a service do not work. I can't tell however if it's because of the script or the way the service is being added (which I've tried a bunch today). Link to comment Share on other sites More sharing options...
MePHiTiC Posted October 25, 2011 Author Share Posted October 25, 2011 Anyone have a sample script that they know works as a script? I'll give that a try and see where I come out. Not sure why this isn't working as planned 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