+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
Windows 7 Thread, Set resolution via GPO in Windows 7? in Technical; Originally Posted by TheScarfedOne in as startup and logon/logoff script to ensure it stays as planned. if you use different ...
  1. #16

    Join Date
    Sep 2011
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by TheScarfedOne View Post
    in as startup and logon/logoff script to ensure it stays as planned. if you use different scripts for staff and students, and or machines, you can achieve what you want to.
    were doing startup and logoff scripts. currently we are using Display Changer from 12 noon. What we notice is that it doesnt always do it, even in the scripts. We have also tried Reschange, but are having the same inconsistent issues with this too. Thats why i wanted to try that powershell script, but i cant get the script linked above to do anything

  2. #17


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,709
    Thank Post
    220
    Thanked 2,615 Times in 1,926 Posts
    Rep Power
    777
    Quote Originally Posted by TerryBloomU View Post
    That's why I wanted to try that PowerShell script, but I can't get the script linked above to do anything
    What is the PowerShell execution policy set to on the clients?

  3. #18

    Join Date
    Sep 2011
    Posts
    5
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    currently not allowed. we are wrapping the call like this (we do this for remoteapp)

    powershell.exe "Set-ExecutionPolicy Unrestricted CurrentUser"
    powershell.exe C:\remoteapp-wcx\Install-RADConnection.ps1 c:\remoteapp-wcx\remoteapp.wcx
    powershell.exe "Set-ExecutionPolicy restricted Currentuser"

    in a cmd file, but doing this i still cant get that powershell script earlier to work. I know someone edited it, but i wanted to know how. maybe i am calling that script wrong?

  4. #19

    Join Date
    May 2008
    Posts
    213
    Thank Post
    2
    Thanked 27 Times in 27 Posts
    Rep Power
    17
    I'm still struggling to get powershell to do things properly - anyone know why qres does not work as a startup script on windows 7?

  5. #20

    Join Date
    Mar 2012
    Location
    Kansas City, Mo
    Posts
    1
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by nicklec View Post
    Anyone using the powershell script as a startup script and/or have you got it working with 'best' resolution too? Trying to add this for our laptops and it doesn't seem to do anything, wondering if the laptop display is somehow not the primary display.
    Just incase i've got the wrong end of the stick, I've pointed the startup script to a .ps1 script with parameters "set-screenresolution -width x -height y"; I presume this is the intended method?

    Would like to avoid qres etc but even running this manually doesn't seem to effect the resolution with zero feedback from the console....

    *edit My coding is too rusty to explain it but removing the function around the code seems todo the trick, then just call the script with x and y numbers for the resolution you want.
    Thank you for the information. You noted that you "removed the function around the code." Can you elaborate on what you removed? I've copied the script into a .ps1 file and placed in into a GPO for machines at startup, but nothing is happening. I've also tried to launch from an elevated cmd, but just wants to open the file. If I click cancel, I receive a message about access denied. Here is what I have:

    Function Set-ScreenResolution {

    <#
    .Synopsis
    Sets the Screen Resolution of the primary monitor
    .Description
    Uses Pinvoke and ChangeDisplaySettings Win32API to make the change
    .Example
    Set-ScreenResolution -Width 1024 -Height 768
    #>
    param (
    [Parameter(Mandatory=$true,
    Position = 0)]
    [int]
    $Width,

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

    $pinvokeCode = @"

    using System;
    using System.Runtime.InteropServices;

    namespace Resolution
    {

    [StructLayout(LayoutKind.Sequential)]
    public struct DEVMODE1
    {
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
    public string dmDeviceName;
    public short dmSpecVersion;
    public short dmDriverVersion;
    public short dmSize;
    public short dmDriverExtra;
    public int dmFields;

    public short dmOrientation;
    public short dmPaperSize;
    public short dmPaperLength;
    public short dmPaperWidth;

    public short dmScale;
    public short dmCopies;
    public short dmDefaultSource;
    public short dmPrintQuality;
    public short dmColor;
    public short dmDuplex;
    public short dmYResolution;
    public short dmTTOption;
    public short dmCollate;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
    public string dmFormName;
    public short dmLogPixels;
    public short dmBitsPerPel;
    public int dmPelsWidth;
    public int dmPelsHeight;

    public int dmDisplayFlags;
    public int dmDisplayFrequency;

    public int dmICMMethod;
    public int dmICMIntent;
    public int dmMediaType;
    public int dmDitherType;
    public int dmReserved1;
    public int dmReserved2;

    public int dmPanningWidth;
    public int dmPanningHeight;
    };



    class User_32
    {
    [DllImport("user32.dll")]
    public static extern int EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE1 devMode);
    [DllImport("user32.dll")]
    public static extern int ChangeDisplaySettings(ref DEVMODE1 devMode, int flags);

    public const int ENUM_CURRENT_SETTINGS = -1;
    public const int CDS_UPDATEREGISTRY = 0x01;
    public const int CDS_TEST = 0x02;
    public const int DISP_CHANGE_SUCCESSFUL = 0;
    public const int DISP_CHANGE_RESTART = 1;
    public const int DISP_CHANGE_FAILED = -1;
    }



    public class PrmaryScreenResolution
    {
    static public string ChangeResolution(int width, int height)
    {

    DEVMODE1 dm = GetDevMode1();

    if (0 != User_32.EnumDisplaySettings(null, User_32.ENUM_CURRENT_SETTINGS, ref dm))
    {

    dm.dmPelsWidth = width;
    dm.dmPelsHeight = height;

    int iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_TEST);

    if (iRet == User_32.DISP_CHANGE_FAILED)
    {
    return "Unable To Process Your Request. Sorry For This Inconvenience.";
    }
    else
    {
    iRet = User_32.ChangeDisplaySettings(ref dm, User_32.CDS_UPDATEREGISTRY);
    switch (iRet)
    {
    case User_32.DISP_CHANGE_SUCCESSFUL:
    {
    return "Success";
    }
    case User_32.DISP_CHANGE_RESTART:
    {
    return "You Need To Reboot For The Change To Happen.\n If You Feel Any Problem After Rebooting Your Machine\nThen Try To Change Resolution In Safe Mode.";
    }
    default:
    {
    return "Failed To Change The Resolution";
    }
    }

    }


    }
    else
    {
    return "Failed To Change The Resolution.";
    }
    }

    private static DEVMODE1 GetDevMode1()
    {
    DEVMODE1 dm = new DEVMODE1();
    dm.dmDeviceName = new String(new char[32]);
    dm.dmFormName = new String(new char[32]);
    dm.dmSize = (short)Marshal.SizeOf(dm);
    return dm;
    }
    }
    }

    "@

    Add-Type $pinvokeCode -ErrorAction SilentlyContinue
    [Resolution.PrmaryScreenResolution]::ChangeResolution($width,$height)
    }

    I then call from the sysvol | policy | machine | startup | SetRes.ps1 with parameter of: Set-ScreenResolution -Width 1024 -Height 600

    After creating, I forced gpupdate and verified the script applied via gpresult /r. Upon restart, nothing!! Your help is greatly apprecited.

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. set the default search provider to google with a GPO
    By Arcath in forum Windows Server 2000/2003
    Replies: 1
    Last Post: 29th April 2010, 01:15 PM
  2. Set the logon screen wallpaper with a GPO
    By Arcath in forum Windows Server 2000/2003
    Replies: 4
    Last Post: 20th October 2009, 10:51 AM
  3. [Ubuntu] virtualbox windows xp screen resolution and networking
    By RabbieBurns in forum *nix
    Replies: 10
    Last Post: 17th June 2009, 06:34 AM
  4. Replies: 5
    Last Post: 17th June 2008, 02:01 PM
  5. set clour scheme through gpo
    By chrbb in forum Windows
    Replies: 2
    Last Post: 21st March 2007, 08:45 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •