Take the 2-minute tour ×

I am playing around with powershell and am changing some taskbar settings by changing the registry key. For example i have written an autohide enable disable function.

$autoHideSettingsPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2";
$autoHideValueName = "Settings";

Function toggleAutohideRegistrySettings($enable)

    $key = Get-ItemProperty -Path $autoHideSettingsPath -Name $autoHideValueName;   

    Write-Host "key is: " + $key
        $key.$autoHIdeValueName[8] = $key.$autoHideValueName[8] -bor 1;

        $key.$autoHIdeValueName[8] = $key.$autoHideValueName[8] -band 0;    

    Set-ItemProperty -Path $autoHideSettingsPath -Name $autoHideValueName -Value $key.$autoHideValueName;

The change in registry works perfectly. But to take effect i need to restart the explorer.exe. Which i can obviously also do in PS... but i noticed that when you apply the autohide settings in the menue (the mouse way), the explorer.exe is not being restarted.

So my question is: how do i apply the changes to the taskbar in the PS, without restarting the explorer.exe?

share|improve this question
add comment

1 Answer

I've used the script above to send message to applications that there are new settings from the registry. Not all application can receive this message but I think explore does.

Give it a try, calling it after registry settings are applied:

$sign = @"
using System;
using System.Runtime.InteropServices;

public static class RegUpdate
    private const int HWND_BROADCAST = 0xffff;
    private static extern int SendMessage(int hWnd, uint wMsg, uint wParam, uint lParam); 

    public static string SendM()
                   SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, INI_INTL);
                   return "0";

                catch (Exception ex)
                    return (ex.Message);              
$type = Add-Type -TypeDefinition $sign -Language CSharp -PassThru
share|improve this answer
This might sound trivial, but how do i call this function? And isn't there a way to do it in native powershell without c# involvement? –  inf.ig.sh Oct 1 '12 at 8:36
You can save it as Send-HWNDMessage.ps1 in your $pwd and call it from powershell as `send-HWNDmessage. P/Invoke can only done via add-type. I don't know any native command to do this. Let me know if it works. –  CB. Oct 1 '12 at 8:52
It does not. I also have found powershell.com/cs/media/p/8322.aspx where the autor claims that he can refresh the explorer settings, does not seem to work with autohide though. –  inf.ig.sh Oct 1 '12 at 8:59
I'm sorry... try to wait other answers. Good Luck. –  CB. Oct 1 '12 at 9:04
Anyway, thanks for your help. –  inf.ig.sh Oct 1 '12 at 9:28
add comment

Your Answer


