Problems with Windows Gadgets

First, I would like to state that I know Microsoft has said gadgets are a bad idea and that there are better alternatives out there. But I do development under Windows 7 and there are a few gadgets that I use everyday and like. For example, the weather gadget and the analog clock with the second hand.

So that being said, it seemed that every couple of days the gadgets wouldn’t start. Initially I tried to fix it with a Reset_Gadgets batch file as presented by Shawn Brink. This worked fine but I wanted to automate the fix so I checked what actually was needed. After some experimentation, it seemed that only killing and restarting the sidebar.exe application was necessary for the gadgets to reappear.

Looking around I found a post by garycase which mentions the problem as being the system booting ‘too fast’ and provides a ‘GadgetsFix.cmd’ to solve the problem. After removing the gadget’s auto-start registry key:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run] “Sidebar”=”C:\\Program Files\\Windows Sidebar\\sidebar.exe /autoRun”

I put ‘GadgetsFix.cmd’ in the start-up folder C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup and while there was the occasional blinking of the gadgets on start-up they always seemed to appear. However, now I would get a Service not available error from the weather gadget every few days.

According to Aaron – G, the problem was fixed by deleting the settings.ini file or by doing just about everything Shawn Brink was doing in his batch file. So while going back to the Reset_Gadgets batch file was certainly an option, I looked more into the settings.ini angle and what I found was that if the config.xml file was saved without making any changes, the gadget services could connect again. Well, this sounded like the config.xml just needed to be ‘touched’ for it to work so I found a little dos command that performs a ‘touch’

COPY /B %1+,, %1

and put it into a batch file. I then edited the batch file ‘GadgetsFix.cmd’ by garycase to include the touch.cmd file and everything seems to work pretty consistently. Here is my edited ‘GadgetsFix.cmd’

@echo off
timeout 2
tasklist /FI “IMAGENAME eq sidebar.exe” 2>NUL | find /I /N “sidebar.exe”>NUL
IF “%ERRORLEVEL%”==”0” (
taskkill /f /im:sidebar.exe
) else (
call touch “C:\Users\xxx\AppData\Local\Microsoft\Windows Live\Services\Cache\Config.xml”
start “” “%ProgramFiles%\Windows Sidebar\sidebar.exe”
)

timeout 1
tasklist /FI “IMAGENAME eq sidebar.exe” 2>NUL | find /I /N “sidebar.exe”>NUL
IF “%ERRORLEVEL%”==”0” (
taskkill /f /im:sidebar.exe
)
else (
call touch “C:\Users\xxx\AppData\Local\Microsoft\Windows Live\Services\Cache\Config.xml”
start “” “%ProgramFiles%\Windows Sidebar\sidebar.exe”
)

exit

This entry was posted in Windows 7 for development. Bookmark the permalink.