Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running as a Service #185

Closed
bladerunner2020 opened this issue Nov 25, 2020 · 7 comments
Closed

Running as a Service #185

bladerunner2020 opened this issue Nov 25, 2020 · 7 comments

Comments

@bladerunner2020
Copy link

When you try to get screenshot in application that is run as a Windows service you get a black screen. This issues was described in #134 and there is also explanation why is it. I read https://docs.microsoft.com/en-us/windows/win32/services/interactive-services but it didn't help. So I believe that something should be changed in the module to interact with user desktop when running as a windows service.

@Mindar
Copy link

Mindar commented Feb 4, 2021

I don't think this is something that screenshot-desktop can fix.

However, the page you linked to clearly outlines how you can fix it for your application:

  1. Create a second (autostart) application that can take screenshots
  2. Communicate with this application via IPC

Alternatively you can create the second process using the Windows API function "CreateProcessAsUser".

@bladerunner2020
Copy link
Author

I don't think this is something that screenshot-desktop can fix.

Why?

  1. Create a second (autostart) application that can take screenshots

Yes, that's obvious solution and what I did )

@Mindar
Copy link

Mindar commented Feb 6, 2021

"can't fix" was probably the wrong formulation. "shouldn't fix" is probably a better way to put it.

Now, I'm not the owner of this repo, so this is really just my personal opinon.

But as a user of this library I wouldn't expect this library to create processes as another user if it's running as a service. I think Microsoft intentionally prevents services from accessing these things directly and I wouldn't expect this library to circumvent this behavior. It should be clearly documented in either case though.

Creating a process as another user probably also has some non-obvious security implications that should be cleared up first.

Personally I believe that this niche is better filled by another library.

@temaivanoff
Copy link

temaivanoff commented Feb 24, 2021

@bladerunner2020
Hi, can you post a sample code of your solution?

@bladerunner2020
Copy link
Author

@bladerunner2020
Hi, can you post a sample code of your solution?

If you run application under a user session (after login) by putting it to autostart not as a service then everything is fine. Just not run it as a service. )))

@temaivanoff
Copy link

@bladerunner2020 Hi, thank. If run from the user, the nodejs console will be visible,
are you using the hide solution in user start ?

@bencevans
Copy link
Owner

After reading around this on and off for a while I'm afraid I've decided this isn't something to include in the library as mostly restricted by the security setup on OSs. As per previous comments, I'd recommend running something at user login. If it's still necessary for your app, I'd be very happy to review a PR but won't be working on this myself.

@bencevans bencevans changed the title Screenshot when running as a service Running as a Service Jun 2, 2021
@bencevans bencevans pinned this issue Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants