coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.79k stars 358 forks source link

How to set argument for script when it starts as service #206

Closed serg-repin closed 6 years ago

serg-repin commented 6 years ago

I have trouble with service/console identification. Maby I can set some arguments when call Service. Then I can find this argument and understand - it is service, or not. A have tryed with 'nodeOptions', but fail. Сan I do this?

AshishShanker commented 6 years ago

One trivial way to do this is to always pass a parameter when invoking the script as an application. With node-windows there is no way to pass any parameters to the script, since it's lifecycle is managed by a wrapper. So if that parameter is undefined inside the script, then you know that the script is running as a service.

Not sure if this would suffice; if not, please describe your use case in more detail.