Getting blank (black) screenshot with automated sc

2019-07-15 12:54发布

问题:

I am trying to troubleshoot a software bug in which we think an app may not be launching every time it is called. To test this, I created a series of scheduled tasks to launch the app, take a screenshot, and then close the app. These tasks are all run through .bat files.

Everything works fine except for the screenshots. When run as a scheduled task, the .jpg from the screen capture always shows a black box. If I execute the .bat file normally, the screenshot looks fine.

I am using nircmd to send the screen capture command and save it to a folder. The command I am using is as follows:

nircmd.exe savescreenshot "C:\File Path\"~$currdate.MMddyyyy$-~$currtime.HHmmss$.jpg

I am using Windows 7.

回答1:

The task created is probably running in its own logon session, even if it is running as the same user.

Make your scheduled task run as the currently logged on user.

Keith Brown wrote an old but still valid detailled explaination of the logon session SID. The relevant part is at the middle, under "http://www.microsoft.com/msj/0599/security/security0599.aspx"

You can also poke around the access rigths with EnumWinStaGui.