bashregistrywindows-10controlpanelsnapping

Control Panel Settings from Command Line


I'm looking for a way to make a Registry Change take affect right away. Specifically the value I want to touch is:

HKEY_CURRENT_USER/Control\ Panel/Desktop/WindowArrangementActive

When you change this setting directly from the Control Panel it takes effect immediately, but when I'm changing it manually, it is not registered before rebooting.

I'm trying to make a script to disable/enable window snapping in Windows 10.

I've currently tried running the following command after the change with no luck:

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True


Solution

  • I ended up getting the job done in C# using the SystemParametersInfo:

    [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
    public static extern bool SystemParametersInfo(int uiAction, int uiParam, IntPtr pvParam, int fWinIni);
    

    and calling it with the following params:

    SystemParametersInfo(0x0083, 0, IntPtr.Zero, 0x001A);
    

    The final param is the one informing the system that the variable has changed in accordance with this documentation by Microsoft:

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms725497(v=vs.85).aspx