Solved Need to write results of NUMEROUS machines reboot to file

May 24, 2012 at 09:32:21
Specs: Windows 7

Good morning, everyone...

I have a batch file that I am running nightly, and I need to have the results written to a results file (doesn't matter what type). Here's my delema.

Here's basically the batch file

SHUTDOWN /r /m \MACHINE1 /t %1 /c "This machine is forcibly restarting in %1 seconds!" /f
SHUTDOWN /r /m \MACHINE2 /t %1 /c "This machine is forcibly restarting in %1 seconds!" /f
SHUTDOWN /r /m \MACHINE3 /t %1 /c "This machine is forcibly restarting in %1 seconds!" /f

It contains approx 248 machines that are rebooted nightly. I would like to be able to write the results of which ones responded, and which ones didn't. More importantly, which ones did. Maybe like a errorlevel==0 and errorlevel==1 type thing? I don't know if that would apply here.

Also. instead of actually listing MACHINE1, MACHINE2, etc. etc., how can I get it to read the machine names from a text file?

This will be ran on a desktop machine behind me as a nightly task if that helps.

How would I do this with having so many numerous entries.

Thank you in advance!

--- Charles!


See More: Need to write results of NUMEROUS machines reboot to file

Report •


#1
May 24, 2012 at 10:18:59
✔ Best Answer
Something like this:

Untested

@echo off
set _=hosts.txt
for /f %%i in (
%_%
) do (
>>output.txt SHUTDOWN /r /m \\%%i /t %1 /c "This machine is forcibly restarting in %1 seconds!" /f
)

Tony


Report •

#2
May 24, 2012 at 10:54:03
Thank you, Tony, for the response.

The filename addition works PERFECTLY! However, it doesn't write anything to output.txt. It just simply runs the command, and restarts the machine. I even ran the batch file while the machine was in a shutdown, because I knew it would error out, and I see the erroring out on the screen (I REM'd the @Echo Off so I could see the results for now), and I see the results on the screen, however, when I add the Echo off statement back in to the batch file, it simply hangs, and then after a few seconds, gives me the error message that the machine name can't be found yada yada yada, but again, nothing written to the output file, although I *do* see it actually exists.


Report •

Related Solutions


Ask Question