The last two months, I was helping a client to get his network running smoothly again. One of the topics were strange errors within various applications and problems with machines that did not received any update from the central Windows Server Update Services.
To cut a long story short, this all was caused by the WMI (Windows Management Instrumentation) service not working correctly. One very often rolled out image was broken in that area so 70% of all computers had a broken WMI installation.
After some research, I created a WMI Fixer batch file that was able to fix the WMI installation of nearly all machines (>400), except three we were forced to reinstall.
Rem Original by David H. Lipman: http://www.pcreview.co.uk/forums/thread-1898592.php
Rem See also: http://www.microsoft.com/technet/scriptcenter/topics/help/wmi.mspx
echo WMI Fixer Batch v1.2
echo Copyright (C) 2008 Xteq Systems
echo Setting TEMP as current directory
cd /d %TEMP%
if exist %WMIRoot% goto Stop_Services
echo WMI doesn't seem to be installed here! Starting WMICore.exe...
echo Creating folder WBEM
echo Trying to stop service...
net stop winmgmt /y
echo Using kill switch to make sure WMI has stopped...
echo Switching to %WMIRoot%
cd /d %WMIRoot%
echo Checking if folder %Rep_Bad% exists and delete it if necessary
if exist %Rep_Bad% rd %Rep_Bad% /s /q
echo Moving current Repository to %Rep_Bad%..
rename Repository %Rep_Bad%
echo Registering all DLL files...
@for %%i in (*.dll) do RegSvr32 -s %%i
echo Registering all EXE files...
for %%i in (*.exe) do call :FixSrv %%i
REM for %%i in (*.mof,*.mfl) do Mofcomp %%i
Rem not used
net start winmgmt
if /I (%1) == (mofcomp.exe) goto SkipSrv
if /I (%1) == (wmic.exe) goto SkipSrv
if /I (%1) == (wbemcntl.exe) goto SkipSrv
if /I (%1) == (wbemtest.exe) goto SkipSrv