DosTips.com

A Forum all about DOS Batch
It is currently 26 Sep 2016 18:09

All times are UTC-06:00




Post new topic  Reply to topic  [ 49 posts ]  Go to page 1 2 3 4 Next
Author Message
PostPosted: 09 May 2012 07:03 
Offline

Joined: 09 May 2012 04:12
Posts: 9
Hi
I have this instruction to fix wmi problem:
for %i in ("wbemcomn.dll") do (echo %~$PATH:i)
for %i in ("wmiutils.dll") do (echo %~$PATH:i)
sc config winmgmt start= disabled
cd /D %windir%\system32\wbem
* Check PID in Regedit (My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\CIMOM ->ProcessID
* kill the Process ID Via Task Maneger.
rmdir /s /q repository
rmdir /s /q Logs
mkdir Logs
for /R %i in (*.dll) do (regsvr32 /s %i) \\ Wait for popup message
regsvr32 /s fastprox.dll
for /R %i in (*.exe) do (%i -regserver)
sc config winmgmt start= auto
regsvr32 wbemupgd.dll
net start server && net start workstation && net start AudioSrv && net start termservice

wbemtest.exe
I want to change it to a batch file
How can i do this
* Check PID in Regedit (My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\CIMOM ->ProcessID
* kill the Process ID Via Task Maneger.
probably use the WMI ,what can I do in another way?
Thanks in advance..


Top
   
PostPosted: 09 May 2012 12:28 
Offline

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Hi, Here is Your Code, Didn't Change Any of The Other Command Except The Lines 27 to 30 "Net Command" made every command in single Line and Changed the % to %% and Replaced i to different letters to avoid any problem "just in case"

And Added The Code For Getting The Process ID and Killing It.
Code:
@ECHO OFF
CLS
FOR %%a IN ("wbemcomn.dll") DO Echo %%~$PATH:a
FOR %%b IN ("wmiutils.dll") DO Echo %%~$PATH:b
SC config winmgmt start= disabled
CD /D %windir%\system32\wbem

::  === This Command Is for Getting The Process ID and Killing It From The Task Manager.
SET "reg=HKLM\SOFTWARE\Microsoft\WBEM\CIMOM"
REG EXPORT "%reg%" "%temp%\reg.txt"
Setlocal EnableDelayedExpansion
FOR /F "tokens=3 delims==dword:" %%c IN ('find /I "ProcessID" "%temp%\reg.txt"') DO set hex=%%c
CALL:toDec %hex% PID
TASKKILL /PID %PID%

::  === This Is For Deleting The <reg.txt> Created with the Command "REG EXPORT" Line9.
DEL /F /Q "%temp%\reg.txt"
::  === Ending The Local and Delayed Extension.
ENDLOCAL DisableEelayedExpansion

RMDIR /S /Q Repository
RMDIR /S /Q Logs
MKDIR Logs
FOR /R %%d IN (*.dll) DO Regsvr32 /S %%d
Regsvr32 /S fastprox.dll
FOR /R %%e IN (*.exe) DO %%e -regserver
SC config winmgmt start= auto
Regsvr32 wbemupgd.dll
NET start server
NET start workstation
NET start AudioSrv
NET start termservice

wbemtest.exe

:toDec
::$created 20091203 :$changed 20091203 :$categories Arithmetic,Encoding
::$source http://www.dostips.com
SETLOCAL
set /a dec=0x%~1
( ENDLOCAL
    IF "%~2" NEQ "" (SET %~2=%dec%) ELSE ECHO.%dec%
)
EXIT /b

:: http://www.dostips.com/forum/

The last Part that start from ":toDec" is for converting the hex value of the process ID to a Decimal value that Task Manager use, cause the registry keep the value when exported in hex.

Hope It Work :)


Top
   
PostPosted: 09 May 2012 22:53 
Offline

Joined: 09 May 2012 04:12
Posts: 9
Hi
It doesn't work fine because at the command taskkill it's output access denied (I told you the taskkill connect to wmi and it's corrupted).
Can you please think about another way to kill the process?


Top
   
PostPosted: 09 May 2012 23:03 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 5959
morb wrote:
Hi
It doesn't work fine because at the command taskkill it's output access denied


Are you running the batch file with elevated privileges?


Top
   
PostPosted: 09 May 2012 23:09 
Offline

Joined: 09 May 2012 04:12
Posts: 9
yes.
I'm running it locally on the computer with the wmi problem.
(there is no problem to me to kill the process manually).


Top
   
PostPosted: 09 May 2012 23:21 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 5959
If you run this batch file what happens?


Code:
@echo off
title ZYZ
for /f "tokens=2" %%a in ('tasklist /fi "windowtitle eq ZYZ"') do set pid=%%a

echo TASKKILL /PID %PID%
TASKKILL /PID %PID%

pause


Top
   
PostPosted: 09 May 2012 23:28 
Offline

Joined: 09 May 2012 04:12
Posts: 9
I got access denied.


Top
   
PostPosted: 09 May 2012 23:50 
Offline
Expert

Joined: 10 Feb 2012 02:20
Posts: 5959
morb wrote:
I got access denied.


At which point? Can you post a screen shot of the dos window?

I'm trying to clarify where the issue is...

What is stopping you from doing it manually?
Does WMIC become corrupted again, and is that because of the file replacement cache in Windows? Is this Windows XP or Win7 etc?


Top
   
PostPosted: 09 May 2012 23:56 
Offline

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Reboot The PC in SafeMode Then Run The Batch Again,
And If It's OK to kill the process Manualy here is the code it wil give u the process ID to kill.
>> Replaced "Taskkill /PID %PID%"
Quote:
@ECHO OFF
CLS
FOR %%a IN ("wbemcomn.dll") DO Echo %%~$PATH:a
FOR %%b IN ("wmiutils.dll") DO Echo %%~$PATH:b
SC config winmgmt start= disabled
CD /D %windir%\system32\wbem

:: === This Command Is for Getting The Process ID and Killing It From The Task Manager.
SET "reg=HKLM\SOFTWARE\Microsoft\WBEM\CIMOM"
REG EXPORT "%reg%" "%temp%\reg.txt"
Setlocal EnableDelayedExpansion
FOR /F "tokens=3 delims==dword:" %%c IN ('find /I "ProcessID" "%temp%\reg.txt"') DO set hex=%%c
CALL:toDec %hex% PID
Echo %PID%
Pause


:: === This Is For Deleting The <reg.txt> Created with the Command "REG EXPORT" Line9.
DEL /F /Q "%temp%\reg.txt"
:: === Ending The Local and Delayed Extension.
ENDLOCAL DisableEelayedExpansion

RMDIR /S /Q Repository
RMDIR /S /Q Logs
MKDIR Logs
FOR /R %%d IN (*.dll) DO Regsvr32 /S %%d
Regsvr32 /S fastprox.dll
FOR /R %%e IN (*.exe) DO %%e -regserver
SC config winmgmt start= auto
Regsvr32 wbemupgd.dll
NET start server
NET start workstation
NET start AudioSrv
NET start termservice

wbemtest.exe

:toDec
::$created 20091203 :$changed 20091203 :$categories Arithmetic,Encoding
::$source http://www.dostips.com
SETLOCAL
set /a dec=0x%~1
( ENDLOCAL
IF "%~2" NEQ "" (SET %~2=%dec%) ELSE ECHO.%dec%
)
EXIT /b

:: http://www.dostips.com/forum/


Top
   
PostPosted: 10 May 2012 00:11 
Offline

Joined: 09 May 2012 04:12
Posts: 9
I don't want to do it manually.
I want is all automatic in silent without any user interaction.
I got this in the screen when I run the batch that foxidrive give.
ERROR: Access denied
TASKKILL /PID
ERROR: Invalid syntax. Value expected for '/PID'.
Type "TASKKILL /?" for usage.
Press any key to continue . . .
I'm running win server 2003


Top
   
PostPosted: 10 May 2012 00:42 
Offline

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Can we use a 3rd Party tool?
If so download this tool and put it in the same folder with the batch, And replace the "taskkill line" in the FIRST BATCH with this code in red
it should look like that:
Quote:
%~dp0\pskill.exe
%~dp0\pskill.exe %PID%


If it worked i can put the batch and the program in one exe file that extract the files and run the batch on click

The Link: http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx

EDIT
sorry forgot to say the first line is for running the prgram first in case it wa the first time just to accept the license


Top
   
PostPosted: 10 May 2012 01:17 
Offline

Joined: 09 May 2012 04:12
Posts: 9
Hi
It's work with pskill
I have just two problems
1. After the pskill command
I got in the next command that the process can not access because it being used by another process
can I need an delay after the pskill?
2.in the command:
FOR /R %%e IN (*.exe) DO %%e -regserver
it run for me the wbemtest.exe
I I don't want any user interaction , how can I skip on reg this exe?
Thanks


Top
   
PostPosted: 10 May 2012 02:02 
Offline

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
about the first problem is it the deletion of the reg.txt file or removing the Repository and log files
try add pause after every command and see where the error happen i tested now but don't getting the first error

and what is wbemtest.exe do exactly?

and the second problem what this -regserver do is it regestring the exe files, if so how?
what this command do exactly
FOR /R %%e IN (*.exe) DO %%e -regserver

i tried it manually one by one for the exe files in the directory and nothing happen the gui window that is pend is wbemtest.exe
if u wan't to skip that i don't really think that the command above do any thing usefull

also the last command wbemtest.exe is the same i think u run this at the end to check if every thing is ok now or not if it's ok to skip it i will post the new code


Top
   
PostPosted: 10 May 2012 02:58 
Offline

Joined: 09 May 2012 04:12
Posts: 9
Hi
1. I saw that I got this message after the pskill when it try to RMDIR /S /Q Repository
2.I don't need the test so you can skip it in the script

Thx


Top
   
PostPosted: 10 May 2012 03:47 
Offline

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
could u check if this file exist on ur pc wbemupgd.dll
when i run the batch it tell that there is a problem with it, when i searched for it couldn't find it.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 49 posts ]  Go to page 1 2 3 4 Next

All times are UTC-06:00


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited