Change resolution of Windows 2012 terminal window

2

0

I have a UI test program which opens a browser to test and then it takes a screenshot at the end of the test. The screenshot comes with good resolution (I can see all the contents on the browser) when I run the program while I logged in to the machine via RDP.

But when I run the program as Windows service, Windows opens the browser in a virtual monitor, or somewhere I cannot see the browser, where the screen size is so small that I cannot see all the contents of the browser.

How can I change the size/resolution of the display Windows opens for services?

Dhana

Posted 2017-03-07T09:53:43.613

Reputation: 1 041

I don't think Windows opens a Window for services, and given that it is not drawing it, probably it can't screenshot something that it doesn't draw – fernando.reyes – 2017-03-07T16:49:20.660

actually I can see a screenshot.. however the image covers only portion of the browser. – Dhana – 2017-03-08T15:38:38.253

1

Do you think this will help you? Now I understand a little bit better what happens there http://stackoverflow.com/questions/18891819/windows-service-screen-capture-returns-black-screen

– fernando.reyes – 2017-03-08T15:40:54.217

This link led me to few other good links as well, all helpful to understand the problem and looks like my process shouldn't be run as a service as its display size may not be as expected. – Dhana – 2017-03-08T16:09:28.913

Answers

1

You can specify the size of the Remote Desktop Connection window by including the /w and /h switches in the command to start the connection.

For example, to connect to the server named MYSERVER with a window size of 1920x1080, use the command:

mstsc.exe /v:MYSERVER /w:1920 /h:1080

You can see the full list of available command-line options by running mstsc /?. Here's the options available on a Windows 7 64-bit Ultimate machine running SP1:

enter image description here

I say Reinstate Monica

Posted 2017-03-07T09:53:43.613

Reputation: 21 477

This is good if the browser is opened in foreground. In my case the browser is not opening in foreground. Its opened in something called session0 it seems, which cannot be controlled manually. Thats what I could gather from internet at least. – Dhana – 2017-03-08T15:38:31.753

I am aware that your RDP session is being opened in Session 0, which you cannot directly observe. Did you edit the command your service is running to include these switches? – I say Reinstate Monica – 2017-03-08T15:48:52.523

I'm not clear about "Did you edit the command your service is running to include these switches?". Lets say I run a java program as service. Where do you suggest I put those switches? – Dhana – 2017-03-08T15:54:09.807

Somehow you're logging in to a RDP session, correct? You use these switches when establishing that session. Now...I'm wondering if I've misunderstood how the RDP session factors into your question. Are you running your service on your local machine (then it creates an RDP session to another machine where the browser is run)? Or are you RDPing to another machine and running the service in the RDP session? – I say Reinstate Monica – 2017-03-08T15:59:01.863

The program runs as a service on a remote machine. I logoff the session when the service runs. – Dhana – 2017-03-08T16:10:49.433

OK, then this answer doesn't apply. I think the root problem is that you're trying to run a user application with a UI as a service. Session 0 isn't really designed to handle applications that expect to display content to a user. – I say Reinstate Monica – 2017-03-08T16:25:15.493