Jump to content

Run a script as a service


Recommended Posts

Hello,

I've read various topics on here about running the script as a service but can't get it to work. Here is the test script I'm running....

#NoTrayIcon

While 1=1
    
    Beep(4000, 200)
    
    Sleep(400)
    
WEnd

Then I create a service with this....

sc.exe create "MyService" binpath= "C:\MyScript.exe" type= own type= interact start= auto DisplayName= "MyService"

The service is created fine. However, when I try to start the service with this....

sc.exe start "MyService"

... I get the following message...

The service did not respond to the start or control request in a timely fashion

Can anyone show me how to actually do this?

Cheers,

JT

Link to comment
Share on other sites

Thanks, I'd already read that earlier on - but I was trying to make use of SC.EXE which is 'meant' to be able to do this. I already tested the script with RunAsSvc and it works fine with that too. Just seems to be SC.EXE which is a problem, though I can't think why.

Link to comment
Share on other sites

I believe SC is simply a commandline interface to the Service Control Manager. It has nothing to do with making non-service executables into services.

You can use the Services UDF mentioned by Whim to accomplish what you want. Else you have to use another tool to launch any exe as a service.

Edited by spudw2k
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...