Screen resolution Change to high

Hi ,

I want to all your help on this, We need to change the Screen resolution through our fixlet to high level like 1366*768, If you have any idea about this or any command can change this means it will more helpful for us.

And i tried with powershell command and for that i create a .bat file to change display resolution its worked when i manually run but through our fixlet its getting failed.

Here below i mentioned the code.

prefetch 88c0a3398d0f9c14b0679c414cc66bcd3731167b sha1:88c0a3398d0f9c14b0679c414cc66bcd3731167b size:1787 http://localhost:52311/Uploads/88c0a3398d0f9c14b0679c414cc66bcd3731167b/Desplay.tmp sha256:4a78da42a8ffecc80f97254b513d4874ac0ce0579d3d54a8792932098d46c437
extract 88c0a3398d0f9c14b0679c414cc66bcd3731167b
wait RunAsCurrentUser.exe "C:\Program Files (x86)\BigFix Enterprise\BES Client_BESData\actionsite_Download\Display\des.bat"

Thanks & Regards
Vicky

Have you tried configuring a BigFix action to run this “As Current User” rather than as the “Local System” user?

No, I am using RunAsCurrentUser.exe for execute this task

Are you sure this file exists when the agent is running the action? I would debug by placing the file permanently to C:\temp\des.bat or by using the file directly in the download folder.

If you would like to upload your fixlet to Bigfix.me, I could take a look at it.

-jgo

The raw XML of the task:

<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
	<Task>
		<Title>Software Distribution - Deploy: Display Resolution</Title>
		<Description><![CDATA[This task will deploy: Display Resolution.<BR><BR>This task is applicable on: Windows 2008, Windows 2008 x64, Windows 7, Windows 7 x64, Windows 2008 R2, Windows 8, Windows 8 x64, Windows 2012, Windows 8.1, Windows 8.1 x64 and Windows 2012 R2. ]]></Description>
		<Relevance>((name of it = "Win2008" AND NOT x64 of it) OR (name of it = "Win2008" AND x64 of it) OR (name of it = "Win7" AND NOT x64 of it) OR (name of it = "Win7" AND x64 of it) OR (name of it = "Win2008R2") OR (name of it = "Win8" AND NOT x64 of it) OR (name of it = "Win8" AND x64 of it) OR (name of it = "Win2012") OR (name of it = "Win8.1" AND NOT x64 of it) OR (name of it = "Win8.1" AND x64 of it) OR (name of it = "Win2012R2")) of operating system AND TRUE</Relevance>
		<Category>Software Distribution</Category>
		<DownloadSize>1767</DownloadSize>
		<Source>Software Distribution Wizard</Source>
		<SourceID></SourceID>
		<SourceSeverity></SourceSeverity>
		<CVENames></CVENames>
		<SANSID></SANSID>
		<MIMEField>
			<Name>x-fixlet-source</Name>
			<Value>Software Distribution Wizard</Value>
		</MIMEField>
		<MIMEField>
			<Name>x-fixlet-modification-time</Name>
			<Value>Fri, 26 Feb 2016 12:04:24 +0000</Value>
		</MIMEField>
		<Domain>BESC</Domain>
		<DefaultAction ID="Action1">
			<Description>
				<PreLink>Click </PreLink>
				<Link>here </Link>
				<PostLink>to initiate the deployment process.</PostLink>
			</Description>
			<ActionScript MIMEType="application/x-Fixlet-Windows-Shell">
prefetch fca6e54285ddcdf2ba8923c5aded6566f8877496 sha1:fca6e54285ddcdf2ba8923c5aded6566f8877496 size:1767 http://ROOT_SERVER_FQDN:52311/Uploads/fca6e54285ddcdf2ba8923c5aded6566f8877496/Desplay.tmp sha256:7cebcd1be59bf171356d681ce9fe3bfabe207233f7337555edaa6ceda86197d6
extract fca6e54285ddcdf2ba8923c5aded6566f8877496
wait RunAsCurrentUser "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\actionsite\__Download\des.bat"
</ActionScript>
			<SuccessCriteria Option="RunToCompletion"></SuccessCriteria>
		</DefaultAction>
	</Task>
</BES>

I have two files into that folder

1.des.bat (Which i try to run from our bigfix)
2.des.ps1 (powershell script for setup the screen resolution)

Hi @jgstew

I need your help on this.

I have two files, one is power-shell script file and another one is batch file, I need to copy and place both files into a client machine on same folder and run the batch file from our bigfix

Please help me to achieve this, when i using following action script its getting failed on last step.

Action Script

prefetch 88c0a3398d0f9c14b0679c414cc66bcd3731167b sha1:88c0a3398d0f9c14b0679c414cc66bcd3731167b size:1787 http://localhost:52311/Uploads/88c0a3398d0f9c14b0679c414cc66bcd3731167b/Desplay.tmp sha256:4a78da42a8ffecc80f97254b513d4874ac0ce0579d3d54a8792932098d46c437
extract 88c0a3398d0f9c14b0679c414cc66bcd3731167b
wait RunAsCurrentUser.exe "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\actionsite\__Download\Display\des.bat" 

Thanks & Regards
Vicky

New action script which i tried now , Its completed successfully but not change the resolution

prefetch 88c0a3398d0f9c14b0679c414cc66bcd3731167b sha1:88c0a3398d0f9c14b0679c414cc66bcd3731167b size:1787 http://Localhost:52311/Uploads/88c0a3398d0f9c14b0679c414cc66bcd3731167b/Desplay.tmp sha256:4a78da42a8ffecc80f97254b513d4874ac0ce0579d3d54a8792932098d46c437
extract 88c0a3398d0f9c14b0679c414cc66bcd3731167b
wait cmd.exe /c mkdir "C:\Display" 
wait cmd.exe /c xcopy "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\actionsite\__Download\Display\des.bat" "C:\Display" /e /i /h
wait cmd.exe /c xcopy "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\actionsite\__Download\Display\des.ps1" "C:\Display" /e /i /h
waithidden cmd.exe /c "C:\Display\des.bat"

This one is running your commands as Local System (the wait and wait hidden) so that won’t affect any user

Additionally the wait to copy is unneeded as there are actionscript commands for that, see: https://developer.bigfix.com/action-script/reference/file/copy.html

Another issue that might be there is we don’t inherit the user’s session when we run as the logged on user so it won’t affect their logged in session at all. This type of operation doesn’t really make sense to change another session’s settings so its not as trivial as it sounds.

1 Like

I am pretty sure bigfix can be used to change screen resolution.

I think this has been used to do this in the past: https://sourceforge.net/projects/qres/

This is another option: http://www.nirsoft.net/utils/nircmd.html

I have never done this using PowerShell. I’m also not certain that it needs to be run as the current user to do this.

If you really want us to be able to debug your code, then you need to provide the contents of the BAT file you are using, as well as the contents of the PowerShell script. Just paste them into the forum and I can fix any formatting issues after the fact.

Also, if you are going to post things to the forum, be sure to redact your root server URL and similar info.

References:

Related:

Hi,

I have tried the file like QRes and NirCmd using our Fixlet , the screen resolution is not change,
should i need to use Any command ?

Thanks,
Nagaraj.

I ran into this issue today and was having the same problem where the command worked when I was on the box, but not via BigFix. Like Alan alluded to, the issue is that the system account is limited to what it can do graphically due to session 0 isolation.

What ended up working for me was creating a small batch file to get the value of the console session, then running the resolution utility using psexec. A similar solution with one of the utilities @jgstew mentioned should work for you as well.

delete __createfile
delete run.bat

createfile until _end_
@echo off
for /f "tokens=3 usebackq" %%i in (`query session console`) do (set CurrSessionId=%%i)
psexec -acceptEula -h -i %CurrSessionId% -c chgres.exe 1024 768 refreshrate=60
_end_

move __createfile run.bat
override wait
hidden=true
completion=job
wait run.bat
2 Likes

Thanks for the follow up @Sean , this is a very helpful batch file you have provided, and not just for this use case.

I haven’t played with PSExec’s other options like influencing different sessions like this, but I can see how it may solve some of the edge cases I run into.

I do wonder if you can get the current session id with relevance somehow.


Related:

You mean this? https://developer.bigfix.com/relevance/reference/logged-on-user.html#session-id-of-logged-on-user-integer

1 Like

Yep, that is what I was looking for just now.

unique values of session ids of (current users;logged on users)

Is there a way to get only console session IDs and not RDP sessions?

I think this is the answer to my own question:

unique values of session ids of (current users;logged on users) whose(not remote of it)
1 Like

Great stuff, thanks guys. Learn something new every day. :slight_smile:

1 Like

This should mean you could do the following: (though definitely would need some testing)

waithidden psexec -acceptEula -h -i { unique value of session ids of (current users;logged on users) whose(not remote of it) } -c chgres.exe 1024 768 refreshrate=60

Yes, exactly. This is what I ended up changing it to:

parameter "DesiredScreenWidth" = "1024"
parameter "DesiredScreenHeight" = "768"
parameter "DesiredRefreshRate" = "60"
parameter "SessionId" = "{unique value of session ids of (current users;logged on users) whose (not remote of it)}"

if {(parameter "DesiredScreenWidth",parameter "DesiredScreenHeight", parameter "DesiredRefreshRate") != (string value of property "CurrentHorizontalResolution" of it, string value of property "CurrentVerticalResolution" of it, string value of property "CurrentRefreshRate" of it) of select object "CurrentHorizontalResolution,CurrentVerticalResolution,CurrentRefreshRate from Win32_VideoController" of wmi}
	waithidden psexec -acceptEula -h -i {parameter "SessionId"} chgres.exe {parameter "DesiredScreenWidth"} {parameter "DesiredScreenHeight"} refreshrate={parameter "DesiredRefreshRate"}
endif

P.S - I tried using the “metric” relevance you referenced in Change Screen Resolution - Policy Action but for whatever reason it didn’t seem to reliably report the current resolution as I was changing it back and forth during testing.

I also got rid of the “-c” argument for psexec, I realized it doesn’t really apply since psexec is calling the exe on the same device. It was a leftover artifact of when it used to be a command called from another device.

1 Like