Repair WMI Remotely

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

ISCS_HWAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ggefterCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kcoectCommented:
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
ISCS_HWAuthor Commented:
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
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

johnb6767Commented:
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
ISCS_HWAuthor Commented:
The batch files are on the remote PC.
0
johnb6767Commented:
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
ISCS_HWAuthor Commented:
see screen shot of what is happening
WMI.jpg
0
johnb6767Commented:
"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
johnb6767Commented:
Why not just use.....

psexec \\remotepc rundll32 wbemupgd, UpgradeRepository
0
johnb6767Commented:
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
ISCS_HWAuthor Commented:
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
AmazingTechCommented:
Why have cmd /c?


FIXWMI.BAT
echo y | net stop winmgmt
ren C:\WINDOWS\system32\wbem\Repository Repository.old
net start winmgmt
0
AmazingTechCommented:
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
ISCS_HWAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows XP

From novice to tech pro — start learning today.