Solved ping computer txt file and run command

September 11, 2011 at 22:43:28
Specs: Windows 7
Hi,

I'd like to have a script for this:
do ping -n2 for all computers in the file c:\remotecomputernames.txt
if the ping is successfull then run this command:
wmic /node:remotecomputername product where name="winrar" call uninstall

Would you please help me with that.
Thank you very much!


See More: ping computer txt file and run command

Report •


#1
September 11, 2011 at 23:27:05
Not so good @ for loops but;
Untested;

for %%j in ("C:\remotecomputernames.txt") do ping %%j -n 2 > nul (
if errorlevel 0 goto :EOF
wmic /node:%%j product where name="winrar" call uninstall
)

Happy is ONE who says I am an OttoMAN.


Report •

#2
September 11, 2011 at 23:42:18
Hi,
I get this output instantly. Nothing really happens :(

C:\>for %j in ("C:\remotecomputernames.txt") do ping %j -n 2 ( 1>nul

C:\>ping "C:\remotecomputernames.txt" -n 2 ( 1>nul

C:\>if errorlevel 0 goto :EOF


Report •

#3
September 13, 2011 at 13:55:17
✔ Best Answer
You would need to create a file called something.bat and then write it like this (also untested):

@echo off

for /F "tokens=*" %%A in (c:\remotecomputernames.txt) do (
ping %A% -n 2 > nul
if errorlevel 0 goto EOF
wmic /node:%A% product where name ="winrar" call uninstall

:EOF


Report •

Related Solutions


Ask Question