Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Screenshot with Windows Service (Win7)

Screenshot with Windows Service (Win7)

Scheduled Pinned Locked Moved C#
csharpcomsecurityquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jacob D Dixon
    wrote on last edited by
    #1

    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.

    M realJSOPR _ 3 Replies Last reply
    0
    • J Jacob D Dixon

      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.

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      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

      J 1 Reply Last reply
      0
      • J Jacob D Dixon

        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.

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • M Mycroft Holmes

          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

          J Offline
          J Offline
          Jacob D Dixon
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • realJSOPR realJSOP

            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

            J Offline
            J Offline
            Jacob D Dixon
            wrote on last edited by
            #5

            Thanks John. I will give that a try to see how it works out.

            1 Reply Last reply
            0
            • J Jacob D Dixon

              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.

              _ Offline
              _ Offline
              _Erik_
              wrote on last edited by
              #6

              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.

              J 1 Reply Last reply
              0
              • _ _Erik_

                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.

                J Offline
                J Offline
                Jacob D Dixon
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups