Screenshot with Windows Service (Win7)
-
So I have been trying to take a screenshot with a windows service... don't think I really have to say I haven't been successful. I think it is because of new security features with Windows 7 that does not allow it to interact with a users session in that way? I have tried using the built in functions for .NET and this code: http://www.codeproject.com/Messages/1705493/how-to-take-a-screenShot-using-windows-service.aspx[^] They just take a black screen. I have also tried setting the service to interact with desktop (still black pic). Now is there is way I can make a service take a screen shot? Also if I can't.. do you think I might be able to make the service start a process (exe I create) that takes a screen shot and saves the file, then teh service grabs that file? I haven't tested it, but was wondering if that would be possible. Wouldn't running the process make it run under console and be able to take a screenshot? First I would like the service to do it, but the process idea is a plan B if that would even work.
-
So I have been trying to take a screenshot with a windows service... don't think I really have to say I haven't been successful. I think it is because of new security features with Windows 7 that does not allow it to interact with a users session in that way? I have tried using the built in functions for .NET and this code: http://www.codeproject.com/Messages/1705493/how-to-take-a-screenShot-using-windows-service.aspx[^] They just take a black screen. I have also tried setting the service to interact with desktop (still black pic). Now is there is way I can make a service take a screen shot? Also if I can't.. do you think I might be able to make the service start a process (exe I create) that takes a screen shot and saves the file, then teh service grabs that file? I haven't tested it, but was wondering if that would be possible. Wouldn't running the process make it run under console and be able to take a screenshot? First I would like the service to do it, but the process idea is a plan B if that would even work.
Jacob D Dixon wrote:
I think it is because of new security features with Windows 7
There is a reason for that, think about it do you want the ability for a service to be able to take a picture of your phone. While I cannot think of a valid reason for this, I can think of plenty of malicious reason to attempt to get a snapshot of a users screen.
Never underestimate the power of human stupidity RAH
-
So I have been trying to take a screenshot with a windows service... don't think I really have to say I haven't been successful. I think it is because of new security features with Windows 7 that does not allow it to interact with a users session in that way? I have tried using the built in functions for .NET and this code: http://www.codeproject.com/Messages/1705493/how-to-take-a-screenShot-using-windows-service.aspx[^] They just take a black screen. I have also tried setting the service to interact with desktop (still black pic). Now is there is way I can make a service take a screen shot? Also if I can't.. do you think I might be able to make the service start a process (exe I create) that takes a screen shot and saves the file, then teh service grabs that file? I haven't tested it, but was wondering if that would be possible. Wouldn't running the process make it run under console and be able to take a screenshot? First I would like the service to do it, but the process idea is a plan B if that would even work.
You can write a conosle app that takes the screen shot, and run that app from the service.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Jacob D Dixon wrote:
I think it is because of new security features with Windows 7
There is a reason for that, think about it do you want the ability for a service to be able to take a picture of your phone. While I cannot think of a valid reason for this, I can think of plenty of malicious reason to attempt to get a snapshot of a users screen.
Never underestimate the power of human stupidity RAH
Well I assure you it isn't for malicious reasons. I'm working on a personal project that monitors computers to get updated information such as hardware info, software, processes, etc. We actually use a software now called LabTech (labtechsoft.com) and I noticed it took screen shots of people's machines (that have the agent installed). I was trying to duplicate that.
-
You can write a conosle app that takes the screen shot, and run that app from the service.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001Thanks John. I will give that a try to see how it works out.
-
So I have been trying to take a screenshot with a windows service... don't think I really have to say I haven't been successful. I think it is because of new security features with Windows 7 that does not allow it to interact with a users session in that way? I have tried using the built in functions for .NET and this code: http://www.codeproject.com/Messages/1705493/how-to-take-a-screenShot-using-windows-service.aspx[^] They just take a black screen. I have also tried setting the service to interact with desktop (still black pic). Now is there is way I can make a service take a screen shot? Also if I can't.. do you think I might be able to make the service start a process (exe I create) that takes a screen shot and saves the file, then teh service grabs that file? I haven't tested it, but was wondering if that would be possible. Wouldn't running the process make it run under console and be able to take a screenshot? First I would like the service to do it, but the process idea is a plan B if that would even work.
-
This is becouse of Session 0 isolation[^] in Windows Vista and Windows 7. I have made no test about it, but I think that any application opened from a service in Session 0 will also be in Session 0, so you'd get the same result.
Ahh crap you are right. Did a test:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.Drawing.Dll
Additonal Information: The handle is invalid