Reputation: 3095
I want to create a windows service from a long running process. I'm able to create the service but I cannot execute it in any way.
I've also tries a very simple timeout.exe
process with the same results.
> New-Service `
-Name "test" `
-BinaryPathName "C:\windows\system32\timeout.exe 30"
// output
Status Name DisplayName
------ ---- -----------
Stopped test test
After that, I'm trying to start service with
Start-Service test
And i receive IMMEDIATELY this output:
Start-Service: Service 'test (test)' cannot be started due to the following error: Cannot start service 'test' on computer '.'.
On event viewer are presente 2 event logs that are referencing a 30 seconds timeout that never happens: the system fails immediately.
What I am missing ?
Upvotes: 0
Views: 938
Reputation: 3095
I'm answering to my own question.
As @alex-k says a regular process cannot be started as service and must be special interface.
In this answer there are additional details https://stackoverflow.com/a/3582179/3120219
srvany.exe is a wrapper that implements the required interface and launch a process but can have some limitations.
Upvotes: 1