# Can't start event daemon on windows any longer ("incorrect function")

**URL:** <https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277>\
**Category:** Pipeline Integrations\
**Tags:** event-daemon\
**Created:** [April 29, 2022, 5:54am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277 "2022-04-29T05:54:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [April 29, 2022, 5:54am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/1 "2022-04-29T05:54:47Z")

</div>

Hi,

after some hiccups with windows I am trying to get the event daemon to work again. It’s the same machine that had been running it just fine for quite some time, but I had to remove the service and add it again for certain reasons.  
When I test the daemon framework in an eleveated powershell it works just fine.

However, when I try to start the service via the Windows Services UI I get an error saying this:

 ![image](https://global.discourse-cdn.com/shotgunsoftware/original/2X/8/8de33ef6f63ba3c9cb0b54db38d4f039e4abcca7.png)

When I check the system event viewer all I get is this very unhelpful message:

 ![image](https://global.discourse-cdn.com/shotgunsoftware/original/2X/a/a832f2c390f52be10006102fd6612e587bafd741.png)

To remove the daemon I used an elevated powershell and ran this command:

```
D:\Python27\python.exe D:\SG_Event_Daemon\src\shotgunEventDaemon.py remove

```

Then I reinstalled it via this command:

```
D:\Python27\python.exe D:\SG_Event_Daemon\src\shotgunEventDaemon.py install

```

When I run it in the foreground like this it works fine:

```
D:\Python27\python.exe D:\SG_Event_Daemon\src\shotgunEventDaemon.py foreground

```

Same when I use debug like so:

```
D:\Python27\python.exe D:\SG_Event_Daemon\src\shotgunEventDaemon.py debug

```

When I try to start it via the powershell instead of the UI it says it is starting the service but it actually fails to start.

What am I missing?

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [April 29, 2022, 7:44am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/2 "2022-04-29T07:44:51Z")

</div>

Try deleting the event daemon data folder, which is configured in the daemon. Specifically `shotgunEventDaemon.py`.  
There are also logs in the same directory, which you could check for more information.

Dude, Python 2.7 has been deprecated for about 10 years, it’s time to switch 🙂  
I think there are fixes in the event daemon github to make it work.

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [April 29, 2022, 8:15am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/3 "2022-04-29T08:15:21Z")

</div>

I did all that, even started entirely new folders (with respectively updated configs).

> > Dude, Python 2.7 has been deprecated for about 10 years

Yeah, I know that but due to the VFX industry being behind by about 10 years this is still fairly recent switch in our world. The event daemon framework itself wasn’t updated to Python 3 for quite some time and since everything was working just fine until about a week ago and went by the old “never change a running system” philosophy (especially seeing I have to look after IT as well as production).

I will try running everything via Pythyon 3 though, maybe a recent windows update decided to no longer accept Python 2.7 as a service command.

Cheers,  
frank

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [April 29, 2022, 8:51am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/4 "2022-04-29T08:51:15Z")

</div>

You should really debug the service startup, and get more logs from there. Not sure how. Does the command line start of the service spit out just this single error message?

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [April 29, 2022, 8:53am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/5 "2022-04-29T08:53:49Z")

</div>

Command line start only says it is starting the service and that’s it. I have to look into the windows event logs to see the above errors.

No idea how to get any more info.

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [May 3, 2022, 6:43am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/6 "2022-05-03T06:43:46Z")

</div>

Did you try  
`Start-Service shotgunEventDaemon`  
from powershell?  
But really if the program gets to the point of writing logs, you should look in those. The directory is configured in the event daemon configuration.

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 3, 2022, 7:07am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/7 "2022-05-03T07:07:41Z")

</div>

```auto
PS C:\WINDOWS\system32> Start-Service ShotgunEventDaemon
Start-Service : Failed to start service 'Shotgun Event Handler (ShotgunEventDaemon)'.
At line:1 char:1
+ Start-Service ShotgunEventDaemon
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand

```

> > But really if the program gets to the point of writing logs, you should look in those. The directory is configured in the event daemon configuration.

It doesn’t get that far, windows fails to start the service, so the SG logs won’t help.And as mentioned before the windows logs just say:

```auto
The Shotgun Event Handler service terminated with the following service-specific error:

Incorrect function.

```

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [May 3, 2022, 9:39am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/8 "2022-05-03T09:39:22Z")

</div>

Hmm ok, I see. Here’s an idea: is the correct function being called by the service? What command does the service call?

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 3, 2022, 9:06pm UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/9 "2022-05-03T21:06:09Z")

</div>

No idea, I guess whatever is set up by  
`shotgunEventDaemon.py install`

I can’t find any info in the service properties or the logs.  
My wild guess is that it is referring to PythonService.exe and possibly the last windows update decided that Python 2.7 is no longer acceptable to run as a service. This is the only thing I can think of but I have not yet had the time to try Python 3 to verify this.

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [May 4, 2022, 7:07am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/10 "2022-05-04T07:07:14Z")

</div>

In the windows service you can see “path to executable”. I don’t know if this also includes any arguments.  
I have not tested `shotgunEventDaemon.py install` (we have our own system). Have you updated the event daemon recently?

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 4, 2022, 7:10am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/11 "2022-05-04T07:10:29Z")

</div>

I did after the trouble started, so I am using the latest version.  
I am about to free up from a marathon show, so will probably raze the lot and get Python 3 on the job. Then report back

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [May 4, 2022, 7:11am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/12 "2022-05-04T07:11:36Z")

</div>

So what does “path to executable” say, I’m curious.

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 4, 2022, 7:33am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/13 "2022-05-04T07:33:43Z")

</div>

“D:\Python27\PythonService.exe”

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 5, 2022, 12:27am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/14 "2022-05-05T00:27:48Z")

</div>

So I installed Python 3.7 with pywin32 then tried to install the service with that as per the GitHub docs. Now I get this:

```auto
PS C:\WINDOWS\system32> D:\Python37_7\python.exe \\10.11.11.101\ohufx\pipeline\tools\python\shotgun_events\src\shotgunEventDaemon.py install
Installing service ShotgunEventDaemon

****WARNING****
The executable at "D:\Python37_7\lib\site-packages\win32\PythonService.exe" is being used as a service.

This executable doesn't have pythonXX.dll and/or pywintypesXX.dll in the same
directory, and they can't be found in the System directory. This is likely to
fail when used in the context of a service.

The exact environment needed will depend on which user runs the service and
where Python is installed. If the service fails to run, this will be why.

NOTE: You should consider copying this executable to the directory where these
DLLs live - "D:\Python37_7\lib\site-packages\win32" might be a good place.
****

```

I tried copying the dlls into the same directory as the exe but got the same error.  
The location where PythonService.exe is run from is controlled by this command ai assume:  
`shotgunEventDaemon.py install`

Where to from here (I’m no windows expert)?

EDIT:  
I just copied the dlls as per the above message and the service installed successfully using Python 3. However, when I try to start it I am still getting an error:

 ![image](https://global.discourse-cdn.com/shotgunsoftware/original/2X/d/dc62857b564bc24407ae6bcd31837ab24cc0e823.png)

The event log now says this:

```auto
The Shotgun Event Handler service failed to start due to the following error: 
The service did not respond to the start or control request in a timely fashion.

```

All utterly unhelpful.

So frustrating after having this working for years…

Cheers,  
frank

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [May 9, 2022, 10:46am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/15 "2022-05-09T10:46:47Z")

</div>

Your `PATH` variable is wrong, it must include the path to `pythonXX.dll` (I guess e.g. `c:\Python38-32`).

Copying dlls is never a good idea (when other solutions are possible).

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 10, 2022, 1:02am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/16 "2022-05-10T01:02:21Z")

</div>

Yeah, I never do this either but wanted to test to see what the actual problem is.  
By now I am getting teh same error as with Python 2 (“incorrectr function”).  
I logged an issue in the github repo but no traction.  
There must be a way to debug this in a constructive manner…

---

<div class="post-metadata">

**Author:** ![anthony.tan](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@anthony.tan](https://community.shotgridsoftware.com/u/anthony.tan)\
**Post date:** [May 10, 2022, 1:21am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/17 "2022-05-10T01:21:17Z")

</div>

FWIW, I’m tried to do the same using a 2.7 install and got something similar - I’m not sure how much free air I’ve got, but I guess sometime this weekend I might have to learn about windows services. How hard could it be?

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 10, 2022, 1:23am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/18 "2022-05-10T01:23:15Z")

</div>

Haha, exactly. The annoying thing is that I set this up two years ago withut trouble and it had been running ever since.  
I set it up for other companies in the past as well without trouble.  
But now I am stuck

---

<div class="post-metadata">

**Author:** ![frank](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/frank/32/247_2.png) [@frank](https://community.shotgridsoftware.com/u/frank)\
**Post date:** [May 10, 2022, 4:10am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/19 "2022-05-10T04:10:47Z")

</div>

@mmoshev I have deleted the copied dlls now and updated my PATH to include those paths:

```
D:\Python37_7\
D:\Python37_7\DLLs
D:\Python37_7\lib\site-packages\win32

```

Rebooted just to make sure, removed and tried to reinstall the servie, but am getting this error again:

 ![image](https://global.discourse-cdn.com/shotgunsoftware/original/2X/c/ca2541ed76e865f5b75cdf6816d3e1612a90ad19.jpeg)

---

<div class="post-metadata">

**Author:** ![mmoshev](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/mmoshev/32/476_2.png) [@mmoshev](https://community.shotgridsoftware.com/u/mmoshev)\
**Post date:** [May 10, 2022, 10:05am UTC](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277/20 "2022-05-10T10:05:00Z")

</div>

Did you check that `pythonXX.dll` and `pywintypesXX.dll` are in these directories?

Did you see that others have asked about the “incorrect function” error?

> <https://stackoverflow.com/questions/6918190/windows-service-incorrect-function>

> <https://stackoverflow.com/questions/26838517/error-in-starting-java-application-as-windows-services>

This also could be an environment problem.

[Next page](https://community.shotgridsoftware.com/t/cant-start-event-daemon-on-windows-any-longer-incorrect-function/15277.md?page=2)
