scripting - Windows batch command to make changes effective immediately -


I have a batch script that lets users change their background from black to white or vice versa. The problem I am facing is that the script only makes an instant change sometimes, and the user has to log out a second time and to change it back in the background, it has to be logged back even though I have So far:

  @echo off call: quiet exit / b: quiet :: For comparison, using the Black Wallpaper registry value set "black = C: \ Users \ UserName \ AppData \ Roaming \ Microsoft \ Windows \ Themes \ MDCBackground_black.bmp ":: Current for current query / F" token = 2 * delims = "%% A IN ('REC query' HKCU \ Control Panel \ Desktop" / V Wallpaper ') DEBIT ON current = %% B: For debugging purpose. ECHO current =% current% stoppage if "% Current% "=="% black% "(Phone: MakeDayWallpaper & gt; Null 2 ​​& gt; & amp; 1: logoff: Rundll32.exe Make changes without requiring user32.dll, UpdatePerUserSystemParameters) and (Call: MakeNightWallpaper & Gt; Null 2 ​​& gt; & amp; 1 :: logoff Rundll32.exe Change without requiring user32.dll, UpdatePerUserSystemParameters) Exclude / b Make: Add MakeDayWallpaper REG "HKCU \ Control Panel \ DES "HKCU \ Control Panel \ Desktop" / v Wallpaper / T. REG_SZ / D "C: \ Users \ Username \ AppData \ Roaming \ Microsoft \ Windows \ Top \" HKCU \ Control Panel \ Desktop / T Add "Desktop" / v Ringtones / T REG_SZ / D " "HKCU \ Control Panel \ Desktop" / v WallpaperStyle / T. REG_SZ / D2 / Object Root "HKCU \ Software \ Microsoft \ Internet Explorer \ Desktop \ General" / v wallpaper / F Exit / b: MakeNightWallpaper REG Add "HKCU \ Control Panel \ Desktop" / v Wallpaper / T REG_SZ / D "" / R Add REG "HKCU System Cell \ Desktop "/ v Wallpaper / T REG_SZ / D" C: \ Users \ Username \ AppData \ Roaming \ Microsoft \ Windows \ Theme \ MDCBackground_black .bmp "/ FREG" \ Microsoft \ Internet Explorer \ Desktop HK HKEY_LOCAL_MACHINE \ Software \ "HKCU \ Control Panel \ Desktop" / v WallpaperStyle / T. REG_SZ / D2 / f Exit / b   

line < Code> RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters is a command that allows instant change. When I look at the shell, I can see that the registry value is changing every time the script is executed, but despite this fact, the background does not change until the user logs in and is logged on.

It may be that until the logoff / logon is over, the registry changes Are not effective (I'm not sure why this happens occasionally do instant work). Try to restart Explorer later and see if it helps.

  taskkill / im explorer.exe / f explorer.exe    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -