How to change "Control Panel" settings without restart via Regedit?

Solution 1:

Many Control Panel customization settings are intended to be updated through the SystemParametersInfo Win32 function. To change the notification message duration, that function can be called with the SPI_SETMESSAGEDURATION action (0x2017). Here is a PowerShell script that takes a parameter specifying the desired message duration in seconds and applies the setting change:

Param(
    [int]$MessageDuration
)

Add-Type @"
using System.Runtime.InteropServices;
public class PInvoke {
    [DllImport("user32.dll")] public static extern int SystemParametersInfo(int uiAction, int uiParam, System.IntPtr pvParam, int fWinIni);
}
"@

[PInvoke]::SystemParametersInfo(0x2017, 0, [IntPtr]$MessageDuration, 3)

The 3 in the last parameter sets both the SPIF_UPDATEINIFILE and SPIF_SENDCHANGE flags so that the new value is written to the Registry and all applications receive a setting-changed notification. If the function succeeds, it returns 1.

To use the script, save it as a PS1 file, e.g. toasttime.ps1. You can then invoke it from a command prompt like so:

powershell -executionpolicy bypass -c .\toasttime.ps1 60

Alternatively, if you just want to apply whatever duration has already been set in the Registry through other means, you can use this variant of the script that reads the desired duration out of the Registry instead of taking a parameter:

Add-Type @"
using System.Runtime.InteropServices;
public class PInvoke {
    [DllImport("user32.dll")] public static extern int SystemParametersInfo(int uiAction, int uiParam, System.IntPtr pvParam, int fWinIni);
}
"@

$accessibility = Get-ItemProperty 'HKCU:\Control Panel\Accessibility'
[PInvoke]::SystemParametersInfo(0x2017, 0, [IntPtr]$accessibility.MessageDuration, 3)

Solution 2:

It is enough to logout and login.

Or you could restart Explorer by:

  • Start the Task Manager
  • Right-click explorer.exe and select "End task", the desktop will disappear
  • Use the menu File > Run new task
  • Enter explorer and click OK
  • The desktop will reappear.