Screen resolution changes while running bot in unattended mode

neel

New Member
Hello,

We are running the bot in attended and unattended way on same VM but resolution is being changed to 1024*768 when run in unattended method.

Bot is tested well in attended mode and it is behaving as expected. But due to change of resolution, the desired result is not coming in unattended mode.

please suggest way to resolve this.
 

koushikk

New Member
Hi Neel

Not sure why resolution changes while you run in unattended mode.Can you change the resolution as soon as the process starts in BluePrism?

Perhaps ,that should solve the issue.

Let me know if you have anything else that figured out
 

neel

New Member
Hi Koushikk,

Thanks for your reply. i am still figuring out how to change the screen resolution before bot run.

Do you have the procedure to do that or any script. My Window is Windows 2008 R2.

i am also searching any power shell script.
 

VJR

Well-Known Member
Hi neel,

I've used it to success on Windows 7 platform so I can't really comment about 2008 R2.
Having said that I don't see it as a reason to not run on other versions since it makes use of Powershell which is a Windows feature.

So then I looked up to see if there's something for 2008 R2 and I found the below link.
https://gallery.technet.microsoft.com/ScriptCenter/2a631d72-206d-4036-a3f2-2e150f297515/

At least by the look of it, it looks to be the same as the script I posted in the original post which is in Powershell too.
And at the bottom of that link it displays a list of platforms where the script has been tested to run on and Windows Server 2008 R2 appears to be one of them. If in doubt you could try running on a test machine and see how it goes.
 

neel

New Member
Hi VJR,

Microsoft also recommend me to run this. i dont know how to run this in power shell.
i copy pasted the code and save as .ps1 file and tried to run it but it is not changing the resolution.

i am still figuring out. Do you have the steps to make it run.
Thanks for your support.
 

tgundhus

Member
Hi Neel

Not sure why resolution changes while you run in unattended mode.Can you change the resolution as soon as the process starts in BluePrism?

Perhaps ,that should solve the issue.

Let me know if you have anything else that figured out

Hello!

Let me do some basic explaining of why this issue occurs. The thing is that when you RDP into the server you are establishing something we call a RDP session and you are using video-resources from the remoting machine and not the server it self. When blue prism log on to the machine using login agent it starts something we call a console session. A console session is similar to the session started when you physically login to a computer. This type of session uses video-resources from the server.

You can also see this if you go into display properties in a remote desktop session, it says the resolution settings cannot be changed during a RDP session. Based on your policy settings and allocated/available video memory your console session will set a screen resolution, the standard for Win2012 is 1024x768. If you try to scale this up to 1920x1080 without having enough video memory available it will max to 1280x800 (I can give more details about max resolutions for different video memory allocations if needed). Anyhow, what you will need to do is to change the screen resolution for the console session. This can only be done from the console session itself, as mentioned above this can be done using powershell (but will only work if you have enough video memory allocated to the server).

Simply create a schedule task launching at login or timed with starts powershell.exe with the script as argument.

If you need more information or guidance, please let me know and lets try to skip all the guessing in the posts :) Good luck
 

VJR

Well-Known Member
Hi VJR,

Microsoft also recommend me to run this. i dont know how to run this in power shell.
i copy pasted the code and save as .ps1 file and tried to run it but it is not changing the resolution.

i am still figuring out. Do you have the steps to make it run.
Thanks for your support.
Hi neel,

I have provided the instructions in the link posted above (posted below now)
http://www.rpaforum.net/threads/setting-resolution-programatically.679/post-1490

It looks like you may have only created the .ps1 file. You also need to create the .bat file with your expected resolution (step no ii. in above link).

Note that '-ExecutionPolicy Bypass' suppresses/bypasses the security policy on your machine to avoid showing a window prompt and so you may want to check with your local IT of your organization to see if that's fine.

After creating the bat file with that one line of command, you can manually just double click the .bat file to see if it works fine. If not then make the necessary amendments using the above link and the other link inside that post.

Once it is working fine, then in your process use the 'Get Screen Resolution' action of 'Utility - Environment' and call the .bat file only if the resolution is not correct.

How to call a bat file from Blue Prism is mentioned in Step no v. of that post.
 

tgundhus

Member
Hi neel,

I have provided the instructions in the link posted above (posted below now)
http://www.rpaforum.net/threads/setting-resolution-programatically.679/post-1490

It looks like you may have only created the .ps1 file. You also need to create the .bat file with your expected resolution (step no ii. in above link).

Note that '-ExecutionPolicy Bypass' suppresses/bypasses the security policy on your machine to avoid showing a window prompt and so you may want to check with your local IT of your organization to see if that's fine.

After creating the bat file with that one line of command, you can manually just double click the .bat file to see if it works fine. If not then make the necessary amendments using the above link and the other link inside that post.

Once it is working fine, then in your process use the 'Get Screen Resolution' action of 'Utility - Environment' and call the .bat file only if the resolution is not correct.

How to call a bat file from Blue Prism is mentioned in Step no v. of that post.


Well written post VJR! :) Sorry, but I have to be honest and say it sounds super stupid to create a bat file, just to run a ps1 file? They are both scripts. Why have a script to run a script? Should you then have a .bat to run the .bat as well?... Ofc I see that this is just an easy way to launch the file, create a bat and place the bat in the startup folder, but seems backwards as well as I think people need to understand what they do in their environments and have control over it.

I have seen the same thing with blue prism, many people making bat files to launch blue prism at startup - insane and totally unnecessary.

My suggestion is to place your ps1 script in a common script folder, and launch this script using a scheduled task. The scheduled task needs an action to start the program "powershell" and the script including execution bypass and the resolution as additional arguments.
 

VJR

Well-Known Member
Well written post VJR! :) Sorry, but I have to be honest and say it sounds super stupid to create a bat file, just to run a ps1 file? They are both scripts. Why have a script to run a script? Should you then have a .bat to run the .bat as well?... Ofc I see that this is just an easy way to launch the file, create a bat and place the bat in the startup folder, but seems backwards as well as I think people need to understand what they do in their environments and have control over it.

I have seen the same thing with blue prism, many people making bat files to launch blue prism at startup - insane and totally unnecessary.

My suggestion is to place your ps1 script in a common script folder, and launch this script using a scheduled task. The scheduled task needs an action to start the program "powershell" and the script including execution bypass and the resolution as additional arguments.
Hi tgundhus,

Since the .ps1 file contains a function and has to be run from an exe along with arguments passed to the exe (of Powershell) which is the extension that Blue Prism takes for a Start Process, that is the approach I've mentioned to @neel. What I've suggested may not be the best approach. So if you do have something permanent, better and an efficient approach then please do feel free to suggest @neel with the same.
 

VJR

Well-Known Member
Hello Guys,

I saved the script in ab.ps1 and then run below command in cmd but it did not change the resolution. is there anything to take into consideration?

View attachment 1354
Hi neel,

There is a different syntax to be used when writing the command directly on the command prompt (eg; usage of double quotes). The suggestion I gave you was to create a .bat file with that command in it and then double click the file manually and check what happens. See if you have appropriate permissions to do so and also make sure you are giving the correct screen resolution.
 

tgundhus

Member
Hi tgundhus,

Since the .ps1 file contains a function and has to be run from an exe along with arguments passed to the exe (of Powershell) which is the extension that Blue Prism takes for a Start Process, that is the approach I've mentioned to @neel. What I've suggested may not be the best approach. So if you do have something permanent, better and an efficient approach then please do feel free to suggest @neel with the same.

You can actually use use start process to start any process, it does not have to be a exe. Blue Prism's "Process start" function, is based on
system.diagnostics.process.start

Hello Guys,

I saved the script in ab.ps1 and then run below command in cmd but it did not change the resolution. is there anything to take into consideration?

View attachment 1354

Yes, it might be! If you read my post a bit further up. To change screen resolution to 1920x1080 it requires 8MB of video-memory (for one monitor). If you have a multi monitor setup:
2 monitors: 25.40MB
3 monitors: 38.00MB
4 monitors: 50.60MB

Please let me know if you use a higher or lower screen resolution. Can you send me more information about how the script was triggered and using which command?
 

tgundhus

Member
Thats because the script you guys are looking at is is "incomplete". It creates the function, but the Set-ScreenResolution function is never triggered.

What you can do it to add this on the VERY top of the script
Code:
param (
[Parameter(Mandatory=$true, Position = 0)]
[int] $Width,

[Parameter(Mandatory=$true, Position = 1)]
[int] $Height
)

and this on the VERY bottom
Code:
Set-ScreenResolution $Width $Height

What this does it to also create the same input parameters for the script (not only the function), and you then at the bottom of the file trigger the function :) Then, you can leave the command part as showed on the screenshot (btw, I suggest you swap out %cd%\ab.ps1, will the full path of the file)
 

VJR

Well-Known Member
Hi neel,

There is a different syntax to be used when writing the command directly on the command prompt (eg; usage of double quotes). The suggestion I gave you was to create a .bat file with that command in it and then double click the file manually and check what happens. See if you have appropriate permissions to do so and also make sure you are giving the correct screen resolution.
Hi neel,

While responding to another thread on the forum I came across an idea to do something like the below.
I ran this and it is working perfectly fine. I've used the script from the earlier link the one that shows under SetRes.ps1.


Refer the below Process Diagram:
View attachment 1531378265789.png

Get Screen Resolution:

Note that there are 2 Output parameters for this action - Horizontal and Vertical Resolutions.
Add both of them.

View attachment 1531378308776.png



Decision stage to check if the screen is already set to the correct resolution:
If it is, then nothing to do. Continue with your process.
If not, then use Start Process to change the resolution.

View attachment 1531378459959.png

Start Process:
Here are the Arguments if you would like it for copy
"-NoProfile -ExecutionPolicy Bypass -File ""C:\Users\Administrator\Desktop\SetRes.ps1"" 1152 864"

You need not hard code anything in the ps1 file nor in any of the below Arguments.
Since as per Blue Prism best practices one needs to make the object reusable as much as possible, you can have separate Data Items for all the three
- ps1 file path
- Horizontal resolution
- Vertical resolution
so that the function in the ps1 file can be used to change any resolution depending upon what parameters you have passed

View attachment 1531378492030.png
 
Last edited:

VJR

Well-Known Member
You can actually use use start process to start any process, it does not have to be a exe. Blue Prism's "Process start" function, is based on
system.diagnostics.process.start
Hi tgundhus,

The point I was trying to make is not the one that you have responded with.
This is what I have mentioned - the .ps1 file contains a function and has to be run from an exe along with arguments passed to the exe
I am referring to three things
i. ps1 file
ii. exe
iii. arguments to the exe with the required resolution.

If there is a way to pass all three of these from the Start Process without the exe and without hard coding the resolutions in the ps1 file keeping it customised then please let me know which would help for any learning there.

On the other hand, we can open a text file simply by giving its path in the Start Process without the exe.
"C:\Users\Administrator\Desktop\Sample.txt" in the Application parameter.
But this will open only if an exe like Notepad or any other editor like Notepad++ is already registered on the system to open files with extension .txt. Secondly it won't necessarily open in the Program/editor we want it to open.

But if by giving the exe in the Application parameter and the path of file as below then it correctly opens the desired file in the desired application.

View attachment 1531380218675.png
 

tgundhus

Member
@VJR @neel
i. the two scripts are not the same, thats why.. :)
ii. seems like we both just use two different ways of getting there. Currently the information of your latest post is correct. It will simple launch the file in it's default program.
iii. if you wish do launch it using blue prism you can do it based on the guide he sent. You can either use the script he posted, or used the one you found and apply my changes.
 
Top