Comment forcer l'arrière-plan du bureau Windows à mettre à jour ou à actualiser


17

Si je modifie manuellement l'image d'arrière-plan dans le registre, comment puis-je la forcer à se rafraîchir sans se déconnecter?

Je sais que bginfo le fait, mais je voudrais garder les choses simples et ne pas utiliser de logiciel.

Réponses:


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

7
Cela ne semble pas fonctionner dans win7 x64 ... quelqu'un a quelque chose qui fonctionne pour ça?
— Jon Kloske

3
L'utiliser comme RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, Truesemble fonctionner sur ma machine (notez la virgule manquante derrière UpdatePerUserSystemParameters)
— Nébuleuse

Peut confirmer, ne rafraîchit pas réellement le bureau sur Win7 x64. J'ai essayé d'appeler les deux versions de RunDll au cas où.
— Okuma.Scott du

3
  • Ouvrir le gestionnaire de tâches
  • Kill explorer.exe
  • Si le shell ne redémarre pas immédiatement
  • Dans le menu, sélectionnez Fichier> Nouvelle tâche
  • Tapez "explorer.exe" et appuyez sur Entrée.

Bonne pensée, mais cela ne résout tout simplement pas.
— Nathan Strutz

2

J'essayais de faire quelque chose de similaire - mettre à jour un paramètre de registre pour le menu de démarrage, puis immédiatement refléter les changements dans le menu de démarrage.

La solution de cette question MSDN a parfaitement fonctionné pour moi.

Vous pouvez essayer de diffuser un WM_SETTINGCHANGEmessage. Par exemple:

class Program
{
    [DllImport("user32.dll", SetLastError = true)]
    private static extern IntPtr SendMessageTimeout(IntPtr hWnd, int Msg, IntPtr wParam, string lParam, uint fuFlags, uint uTimeout, IntPtr lpdwResult);

    private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
    private const int WM_SETTINGCHANGE = 0x1a;
    private const int SMTO_ABORTIFHUNG = 0x0002;

    static void Main(string[] args)
    {
        SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, IntPtr.Zero, null, SMTO_ABORTIFHUNG, 100, IntPtr.Zero);
    }
}

1

Modifiez la résolution d'écran, puis choisissez l'option de retour. Votre résolution restera la même et l'arrière-plan aura changé.

Vous pouvez également déconnecter et reconnecter le câble d'écran.


1
# first in powershell, second both. cmd.exe + powershell.exe

# Refresh Desktop Ability
$definition = @'
    [System.Runtime.InteropServices.DllImport("Shell32.dll")] 
    private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
    public static void Refresh() {
        SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);    
    }
'@
Add-Type -MemberDefinition $definition -Namespace WinAPI -Name Explorer

# Set Safe within deleted days and get physical drive letters
$ignoreDeletedWithinDays = 2
$drives = (gwmi -Class Win32_LogicalDisk | ? {$_.drivetype -eq 3}).deviceid

# Process discovered drives
$drives | % {$drive = $_
    gci -Path ($drive+'\$Recycle.Bin\*\$I*') -Recurse -Force | ? {($_.LastWriteTime -lt [datetime]::Now.AddDays(-$ignoreDeletedWithinDays)) -and ($_.name -like "`$*.*")} | % {

        # Just a few calcs
        $infoFile         = $_
        $originalFile     = gi ($drive+"\`$Recycle.Bin\*\`$R$($infoFile.Name.Substring(2))") -Force
        $originalLocation = [regex]::match([string](gc $infoFile.FullName -Force -Encoding Unicode),($drive+'[^<>:"/|?*]+\.[\w\-_\+]+')).Value
        $deletedDate      = $infoFile.LastWriteTime
        $sid              = $infoFile.FullName.split('\') | ? {$_ -like "S-1-5*"}
        $user             = try{(gpv "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\$($sid)" -Name ProfileImagePath).replace("$(gpv 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\ProfileList' -Name ProfilesDirectory)\",'')}catch{$Sid}

        #' Various info
        $originalLocation
        $deletedDate
        $user
        $sid
        $infoFile.Fullname
        ((gi $infoFile -force).length / 1mb).ToString('0.00MB')
        $originalFile.fullname
        ((gi $originalFile -force).length / 1mb).ToString('0.00MB')
        ""

        # Blow it all Away
        #ri $InfoFile -Recurse -Force -Confirm:$false -WhatIf
        #ri $OriginalFile -Recurse -Force -Confirm:$false- WhatIf
        # remove comment before two lines above and the '-WhatIf' statement to delete files
    }
}

# Refresh desktop icons
[WinAPI.Explorer]::Refresh()

or 

ie4uinit.exe -ClearIconCache

end scripting enjoy.
#end

1
Cela a l'air sympa, mais pourquoi tous les trucs d' entraînement là-dedans?
— not2qubit

0

La ligne de la réponse acceptée a fonctionné pour moi de manière très sporadique. J'ai fini par écrire une boucle while pour appeler le code en silence 25 fois en arrière-plan. J'espère que cela t'aides.

Code de la réponse acceptée:

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters 1, True

Code du haut de mon script bash:

desktop () {

i=0

# Tell the desktop to refresh 25 times.
while [ $i -le 25 ]
do
  echo "RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters, 1 True"| "C:/Windows/System32/WindowsPowerShell/v1.0/powershell"
  ((i++))
done

}


# This runs the function silently as a background process
desktop &>/dev/null &
En utilisant notre site, vous reconnaissez avoir lu et compris notre politique liée aux cookies et notre politique de confidentialité.
Licensed under cc by-sa 3.0 with attribution required.