Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Installing a service.

  • 20-08-2007 11:56am
    #1
    Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭


    I'm not quite sure this is the right place. Maybe a windows forum?
    Anyway, I am trying to install a service, coding in XML.
    When I try to start the service I get 'The service did not respond to the start or control request in a timely fashion', has anybody encountered this, or a way to fix it?


Comments

  • Closed Accounts Posts: 669 ✭✭✭pid()


    Could you post a snippet of your code so we can see how you are creating and registering the service?


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    Sure.
    <Component Id="Wrapper" Guid="{B54860D3-DD3F-45EA-803D-CD605597DAAF}">
                  <File Id="FL_service.cmd" Name="service." LongName="service.cmd" Source="inputfiles\service.cmd" DiskId="1" KeyPath="yes" />
                  <ServiceInstall Id="NewService1" ErrorControl="normal" Name="PService2" Start="auto" Type="ownProcess">
                  </ServiceInstall>
                  <ServiceControl Id="NewService1" Name="PService2" Remove="uninstall" />
                </Component>
    

    A service can be a .cmd? or is there a guideline type of file they are looking for?
    Maybe a service has to be a .exe. for example? No?


  • Closed Accounts Posts: 669 ✭✭✭pid()


    It may actually have to be an exe. Is the account you're using an administrator account? If it's not you may not be allowed to create a service.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    When I set the service to install automatically as I run my installer, it gives an error saying I don't have enough privileges all right. So I set it to not install a service until I wanted to start it, then I got this error. I thought I was administrator, I have never had any rights problems though. These work computers are weird, you never know what rights you have.

    I have seen the same problem on google, I can't see any solutions though and I doubt it is administrator rights for everybody. Hmm.
    If it is only .exe's I have a problem.


  • Closed Accounts Posts: 669 ✭✭✭pid()


    When I set the service to install automatically as I run my installer, it gives an error saying I don't have enough privileges all right. So I set it to not install a service until I wanted to start it, then I got this error. I thought I was administrator, I have never had any rights problems though. These work computers are weird, you never know what rights you have.

    I have seen the same problem on google, I can't see any solutions though and I doubt it is administrator rights for everybody. Hmm.
    If it is only .exe's I have a problem.


    Yeah I think the issue is both .exe and admin rights. If it's a work computer they probably won't allow you to have admin rights. Do you have VMware installed? You could use that to test this out. I'm trying to remember whether it allows services of other types (i.e not an exe). as it has been a while since I developed a custom service. I can't find much on google in relation to that, but someone please correct me if I'm wrong.


  • Advertisement
  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    I could try VMware thanks, until the network admin comes back from holidays my rights won't be changed.
    I will try to find out about it just being a .exe thanks.

    Maybe make it so a script will start the service after install, if I can, instead of installing a .cmd as a service.
    Thanks


  • Moderators, Technology & Internet Moderators Posts: 37,485 Mod ✭✭✭✭Khannie


    Sounds like vmware's your best bet for now alright. Pity you need an extra licence for it for windows though. :(


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    you do? cry.

    Anyway, I have learned that it does have to be a .exe I believe.
    atm I can install a notepad.exe as a servive and it pops up when I try to stop the service. It then closes as the progress bar goes forward and I get an error. :/


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Could you try Microsoft Virtual PC?


  • Registered Users Posts: 4,188 ✭✭✭pH


    I'm a little confused here as to what exactly you're trying to do.

    If this is a service for windows (NT/XP etc) then it not only needs to be an exe but also needs to be able to interact with the Services Control manager. Windows services are a special kind of application.

    There are however wrapper programs (for example srvany) that will allow any exe be run as a windows service.

    http://www.windowsitpro.com/Articles/Index.cfm?ArticleID=8148&DisplayTab=Article


  • Advertisement
  • Registered Users Posts: 2,426 ✭✭✭ressem


    Batch files (.cmd) aren't meant to be allowed run as services. In which case instsrv/srvany won't succeed.

    If it's for personal/ one-off use, as opposed to a program to be sold, then a bit of commercial software called firedaemon will work. http://www.firedaemon.com/ , with a time limited trial version available.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 90,664 Mod ✭✭✭✭Capt'n Midnight


    could cmd.exe be a service and get it to call the .cmd ?

    or compile the script


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I'm pretty sure like others have said it has to be an exe/dll with particular functions and properties to allow it to run as a service.

    What are you trying to achieve with the .cmd, could it simply be scheduled to run at intervals or to run on startup ?


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    Thanks for all the help. My problem first of all, is that i didn't know the exe needed special properties. I'll get on it if I can. Moving on to localization for now.
    If it's for personal/ one-off use, as opposed to a program to be sold, then a bit of commercial software called firedaemon will work. http://www.firedaemon.com/ , with a time limited trial version available.
    Unfortunately it is for neither. :)


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    If it's possible for you to use it, Visual Studio 2005 does a lot of the work for, you can just choose "Windows Service" as the project type and it'll create the project for you with everything you need, all you need to do is add the code for what your service does, and any custom startup or shutdown actions. You can easily add an installer project to it too to install your service.

    (not sure if this functionality is available in the free express versions or not)


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    stevenmu wrote:
    If it's possible for you to use it, Visual Studio 2005 does a lot of the work for, you can just choose "Windows Service" as the project type and it'll create the project for you with everything you need, all you need to do is add the code for what your service does, and any custom startup or shutdown actions. You can easily add an installer project to it too to install your service.

    (not sure if this functionality is available in the free express versions or not)
    Thanks Steven, I found out about that yesterday and believe we know have a proper exe which runs a file to run the cmd. :)
    Still getting the same error however, so I'm looking around for more reasons why it is not responding in a 'timely fashion'.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    Are you calling the cmd file directly when the service starts ?. IIRC there's a start() or servicestart() (or something like that) function in your service that gets called when windows tries to start the service. If this doesn't complete pretty quickly you'll get an error so you should just use it to initialise anything that needs to be, well, initialised.

    If you're running the cmd directly from here then that could be your problem. You should look at trying to kick off the cmd some other way. One way would be to use a timer, you would use your start() or servicestart() or whatever to kick off the timer, then in the timer event you would call the cmd file (and maybe stop the timer depending on whether you want the cmd to keep being called or not.) IIRC for services you can't just drop the normal timer control in, you have to use the one in the service API, but that's pretty simple, google should turn up some code samples.

    Oh, and if you get a permissions error again it could be because the service needs permission to interact with the desktop, if you go to the service manager and right-click on yours to get it's properties, the Log-on tab shows what user the service runs under and if it has permission to interact with desktop or not.


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    stevenmu wrote:
    Are you calling the cmd file directly when the service starts ?. IIRC there's a start() or servicestart() (or something like that) function in your service that gets called when windows tries to start the service. If this doesn't complete pretty quickly you'll get an error so you should just use it to initialise anything that needs to be, well, initialised.

    If you're running the cmd directly from here then that could be your problem. You should look at trying to kick off the cmd some other way. One way would be to use a timer, you would use your start() or servicestart() or whatever to kick off the timer, then in the timer event you would call the cmd file (and maybe stop the timer depending on whether you want the cmd to keep being called or not.) IIRC for services you can't just drop the normal timer control in, you have to use the one in the service API, but that's pretty simple, google should turn up some code samples.

    Oh, and if you get a permissions error again it could be because the service needs permission to interact with the desktop, if you go to the service manager and right-click on yours to get it's properties, the Log-on tab shows what user the service runs under and if it has permission to interact with desktop or not.
    I set it up so that the program installs, I then go to services and press start to get the error.
    I will look into a timer thanks.

    I noticed the 'interact with the desktop' box all right, is there a way to have it enabled on install?


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    I don't think so, but I did a quick google and there's a workaround here


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    I got my service working, thanks for all the help people, especially Steven.
    There were various problems with it. Interacting with the desktop was not an issue.
    My installer, she is great! :-)


  • Advertisement
Advertisement