I am writing a Batch to uninstall a sofware from a domain envirement but stuck. The problem is that i need a return value to a variable of the wmic uninstall call but get nothing if its an RPC error,not even an errorlevel but i need it to separate the good and bad ones in a logfile.
setlocal enableextensions EnableDelayedExpansion
@echo off
set v=
echo Nem voltak elerhetok > nemelerheto.txt
echo Hibakk > log.txt
echo. >>log.txt
FOR /F "tokens=*" %%v in (runtime2k3.txt) do (
IF Not !volt!==%%v (
echo %%v >> log.txt
echo %%v
for /f %%p in ('ping -n 1 %%v ^| find /c "(0%% loss)"') do (
if %%p==1 (
echo elerheto
echo elerheto >> log.txt
wmic /output:wmic.txt /user:****** /password:"******" /node:%%v product where name^="Microsoft Office Access 2003 Runtime" call uninstall
)
if %%p==0 (
echo %%v >> nemelerheto.txt
echo nemelerheto >> log.txt
)
)
set array[!i!]=%%v
set volt=%%v
set /a i=!i!+1
)
echo. >> log.txt
)
There is no way to produce something in WMIC
in the way you are using it. You only pass a global switches eg test :
wmic /node:no_such_server
To make wmic to do something use some of the commands/aliases. -> http://ss64.com/nt/wmic.html
to check the sever try something harmless and short eg wmic timezone get Bias
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.