?
Solved

Repair WMI Remotely

Posted on 2010-03-31
14
Medium Priority
?
7,866 Views
Last Modified: 2012-05-09
I am trying to repair WMI on client machines remotely. I have this set so that I will run PSEXEC (from the PS Tools suite from SysInternals) on the remote machine, with my domain admin account. It runs a batch file named CALL.BAT (attached), which calls the batch file FIXWMI.BAT (attached). I do this because if I ran the FIXWMI.BAT from the PSEXEC utility, it failed with access denied. When I run PSEXEC on the CALL.BAT file, it runs through a bit better, but seems to want a response from me when running the call c:\fixwmi.bat command in the CALL.BAT file.

Are there any ideas on how I may be able to fix the batch files, or how to repair WMI on a remote computer?
CALL.BAT
call c:\fixwmi.bat


FIXWMI.BAT
cmd /c echo y | net stop winmgmt
ren C:\WINDOWS\system32\wbem\Repository Repository.old
cmd /c net start winmgmt

Open in new window

0
Comment
Question by:ISCS_HW
  • 5
  • 5
  • 2
  • +2
14 Comments
 
LVL 8

Accepted Solution

by:
ggefter earned 220 total points
ID: 29261344
0
 
LVL 8

Expert Comment

by:kcoect
ID: 29261571
Try also running the script as a STARTUP script and not a login script.  If it runs as a STARTUP script, I believe it runs under the local SYSTEM account, which would have the rights that you need for the script to run.
0
 

Author Comment

by:ISCS_HW
ID: 29262404
ggefter:

II tried the rundll32 to portion to update WMI, I will get back to you on if it works after the computer is restarted. I don't want to have to locally login to each system to fix the issue, as the broken systems are in multiple countries.

kcoect:

I don't want to set this as a startup, as I don't want it to be "repaired" every time someone logs in to the machine.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
LVL 66

Expert Comment

by:johnb6767
ID: 29263610
PsExec....
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

psexec \\remotepc -c fixwmi.bat

Just make sure that psexec is in the same directory as the .bat file.....

-c copies it to the \\remotepc and executes it on the target
0
 

Author Comment

by:ISCS_HW
ID: 29263670
The batch files are on the remote PC.
0
 
LVL 66

Assisted Solution

by:johnb6767
johnb6767 earned 200 total points
ID: 29263870
Repairing and re-registering the WMI
http://windowsxp.mvps.org/repairwmi.htm

For that matter you can use psexec on any of these methods.....

You have the first one in the bat file.....

For example, to rebuild the whole darn thing......

psexec \\remotepc rundll32.exe setupapi,InstallHinfSection WBEM 132 %windir%\inf\wbemoc.inf

Oh, and if you are loggged on currently as a user who has rights to the remote pc's the -u and -p switches are not needed.....
0
 

Author Comment

by:ISCS_HW
ID: 29264200
see screen shot of what is happening
WMI.jpg
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 29264407
"The batch files are on the remote PC."

psexec \\remotepc "C:\Path\To\fixwmi.bat"

Or just launch a remote command shell......

psexec \\remotepc cmd.exe

Then just navigate it locally......
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 29265289
Why not just use.....

psexec \\remotepc rundll32 wbemupgd, UpgradeRepository
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 29265647
Dont wanna logon to each pc?

psexec @C:\PCNames.TXT -d rundll32 wbemupgd, UpgradeRepository

C:\PCNames.txt is self explanatory, just populate the ones you wanna hit......

0
 

Author Comment

by:ISCS_HW
ID: 29265835
I am trying that now as mentioned by ggefter

I am also trying re-registering the components you suggested from http://windowsxp.mvps.org/repairwmi.htm

I will let you know how each works.
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 29348765
Why have cmd /c?


FIXWMI.BAT
echo y | net stop winmgmt
ren C:\WINDOWS\system32\wbem\Repository Repository.old
net start winmgmt
0
 
LVL 21

Assisted Solution

by:AmazingTech
AmazingTech earned 80 total points
ID: 29349811
Here's the script that I use.  You'll have to make sure the repository.old does not already exist otherwise the script bypasses fixing it since it thinks it's already been done.

cd /d %systemroot%\system32\wbem

net stop winmgmt /n | find "  "
IF ERRORLEVEL 1 (
    net stop winmgmt /y
    ping -n 10 loopback>nul
    IF NOT EXIST %windir%\system32\wbem\repository.old (
        REN %windir%\system32\wbem\repository repository.old
        mofcomp cimwin32.mof
        mofcomp cimwin32.mfl
        mofcomp rsop.mof
        mofcomp rsop.mfl
        for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
        for /f %%s in ('dir /b *.mof') do mofcomp %%s
        for /f %%s in ('dir /b *.mfl') do mofcomp %%s
    )
    net start winmgmt
) ELSE (
    for /f "tokens=*" %%a in ('net stop winmgmt /y ^| find "  "') do (
        ping -n 10 loopback>nul
        IF NOT EXIST %windir%\system32\wbem\repository.old (
            REN %windir%\system32\wbem\repository repository.old
            mofcomp cimwin32.mof
            mofcomp cimwin32.mfl
            mofcomp rsop.mof
            mofcomp rsop.mfl
            for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
            for /f %%s in ('dir /b *.mof') do mofcomp %%s
            for /f %%s in ('dir /b *.mfl') do mofcomp %%s
        )
        NET START "%%a"
    )
)
0
 

Author Closing Comment

by:ISCS_HW
ID: 31709630
The fix by ggefter worked for some of my workstations, and the others were fixed thanks to johnb6767. The script by AmazingTech was also helpful so I did not need to create my own script for this.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Suggested Courses

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question