SOLVED

Need to Change and Apply Ease of Access Aero-Snap settings with batch script without a restart

Contributor

We need to change and APPLY the Aero-Snap setting from the Ease of Access control panel, without a restart or logoff/logon in a Windows 10 Enterprise x64 20H2 non-persistent VDI environment.  We know that the Registry value (at least) HKCU\Control Panel\Desktop\WindowArrangementActive (0 or 1 value) controls the "Prevent windows from being automatically arranged when moved to the edge of the screen" setting.   The problem is that while our User Profile management system saves and then restores this Registry value during a later LOGIN, there appears to be a timing issue that prevents it from being activated.  As a stop gap measure, we would like to execute a BATCH script to change and APPLY the user's desired setting during their current Startup script's execution.  Setting the Registry value is the EASY part.  I need information on how to APPLY the setting "programmatically" in a .BAT file (I am NOT a C++, C# or Power Shell programmer).  I would expect that if such a command exists (rundll32.exe ????), it may also APPLY many other settings in the Registry that were changed but not yet activated.  In other words, we want a "program/command" that essentially hits the "Apply" button in the Control Panel.  There may be other Registry keys/values involved in this that we could add to the mix of Save at logoff and Restore at login, but we need to APPLY them in the current login session.  Restart or Logoff/Login is NOT an option obviously.  There do not appear to be any Domain or Local GPO's affecting this operation.  The setting always appears to ALLOW window arrangement  when they are moved to the screen edge, which is undesirable by many users.  Cycling explorer.exe does NOT activate the new setting (much to my surprise).  We are also aware of the SnapAssist, SnapFill, and JointResize Registry values in HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced key.  My own IT department PC has had the Aero-Snap settings under Settings -> System ->Multitasking changed but those ...Explorer\Advanced values have NOT appeared in its Registry.

Your help with this matter is greatly appreciated!

 

ChevITGuy

4 Replies

@ChevITGuy 

Running a ProcMon session to capture C:\Windows\explorer.exe activity just before, during, and just after the "Apply" button is pressed on the Ease of Access panel, reveals approximately 48 "RegSetValue" operations which may include new related anti-virus security Registry values similar to the "StuckRects3" Settings value that are changed when a user adds/removes an icon from the Taskbar ("HKCU\SOFTWARE....\Explorer\Taskband").  Since we are NOT desiring to CHANGE the Aero-Snap setting on our non-persistent VDI sessions but only SAVE at Logoff and RESTORE at Login time, I will pursue the list of Registry Keys/Values and determine if they need to be added to the user profile management settings for save/restore.  It would make sense that settings that do not match their accompanying "security values" at login time, would be overridden by perhaps .DEFAULT user settings by the operating system.

 

ChevITGuy

@ChevITGuy

The Settings -> System -> Multitasking panel has the "Snap windows" On-Off button that I am currently working with.  Turning Snap windows button to ON and then UNCHECKING the three check boxes below, causes the SnapFill, JointResize, and SnapAssist Registry values to show up (value 0) in the HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced Registry Key.  Again, saving and restoring this key is still not enough to keep the "Snap windows" button to be in the OFF position at the next login cycle in our non-persistent Win 10 Enterprise 64-bit Feature 20H2 systems.

 

ChevITGuy

@ChevITGuy

Thanks to our User Profile Management support desk, we were able to locate Michael Albert's posting on Michael's own technical blog from July 16, 2013 using Power Shell to Disable the Aero Snap feature.  I have NOT tried his posting on Windows 10 Professional or Enterprise x64 Feature 20H2 yet.  Find Michael Albert's posting by searching on "SystemInfoByRef" in your favorite search engine.  Michael's Power Shell script references the SPI_GETWINARRANGING (0x0082) and SPI_SETWINARRANGING (0x0083) API's from the System Parameters Info API set.  His site offers a Download of "DisableAeroSnap.ps1" file for your examination.  I've asked my User Profile Management support team members to see if their developers can generate a .EXE file and will read the HKCU\Control Panel\Desktop\WindowArrangementActive value (0 or 1) from the Registry and activate the appropriate Enable/Disable condition for the Aero Snap feature.

 

ChevITGuy  

best response confirmed by ChevITGuy (Contributor)
Solution

@ChevITGuy

   I was able to modify the aformentioned Powershell script using the Get-ItemProperty and the Write-Output cmdlets to set a value to 1 or 0 based from the HKCU\Control Panel\Desktop\WindowArrangementActive registry value.  This value is previously set by the user profile management software in our login process.  I then "copied" my derived 0 or 1 value to the iParameter input variable for the SPI_SETWINARRANGING operation.  This worked excellently as evidenced by many test logins and logouts using three regular non-privileged user ID's.  If the user set the Checkmark on the Ease of Access panel before logoff, the subsequent login session had it CHECKED and vice versa.  This solution appears to be one that could enable or disable programmatically the Aero Snap feature in Windows 10 after a change in the WindowArrangementActive registry value.  Our user profile management team continues to look for their own resolution to the issue.  I'll mark this as best answer so far.

 

ChevITGuy