Screen capture of Server console screen RRS feed

  • Question

  • Using VS 2012 and .NET 4.0 on Windows Server 2008 R2.

    We leave the Admin user logged into the Server using remote desktop.  The batch jobs run via the Task Scheduler as the Admin user, and any output is displayed on the Admin user screen.   The Admin user screen is, of course, a disconnected Remote Desktop session.

    I would like to setup a Task Scheduler job to capture the Admin user screen and email to me once a day.  This would allow me to view any errors that did not get communicated to me via .NET exceptions.

    I have code that will do a screen capture and write it to a file.  It works locally.  When I setup a scheduled job to run-as the Admin user, I get this error:

    System.ComponentModel.Win32Exception (0x80004005): The handle is invalid

    Here is the code:

      Using bitmap As New Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
          Using g As Graphics = Graphics.FromImage(bitmap)
              g.CopyFromScreen(0, 0, 0, 0, bitmap.Size)
          End Using
          bitmap.Save("C:\temp\ScreenCapture.jpg", ImageFormat.Jpeg)
      End Using
    Thanks for any ideas


    Friday, September 12, 2014 9:23 PM


All replies