I am in need of assistance. I have a batch file that runs nightly to restart machines in a specified list (restartmelist.txt) which works flawlessly. What I am looking to do, is have another file (restartmenames.txt) with a list of usernames, so when I look at the results file, I can not only see the results from each machine, but also whose machine it is. The names correlate in order with the machines. So restartmelist.txt looks like this:
MACHINE1
MACHINE2
MACHINE3
And restartmenames.txt looks like this:
Bob Lastname
Bill Lastname
Jason Lastname
Right now, my log-file writes like this:
.Machine1
.Machine2
.Machine3
What I would like to see, is this:
.Machine1 (Bob Lastname)
.Machine2 (Bill Lastname)
.Machine3 (Jason Lastname)
What I don't know how to do, is call that 2nd file to write the log entries, or if it's even possible. Here is what my code currently looks like:
[cpp]@ECHO OFF
FOR /F "tokens=*" %%A IN ('TIME/T') DO SET Now=%%A
>>c:\scripts\Restartme.log 2>&1 Echo Restarting of machines STARTED on %date% @ %now%
>>c:\scripts\Restartme.log 2>&1 Echo.
set _=c:\scripts\restartmelist.txt
for /f %%i in (
%_%
) do (
>>c:\scripts\Restartme.log 2>&1 SHUTDOWN /r /m \\%%i /t %1 /c "This machine is forcibly restarting in %1 seconds!" /f
>>c:\scripts\Restartme.log 2>&1 Echo . %%i
)
FOR /F "tokens=*" %%B IN ('TIME/T') DO SET NowDone=%%B
>>c:\scripts\Restartme.log 2>&1 Echo.
>>c:\scripts\Restartme.log 2>&1 Echo Restarting of machines COMPLETED on %date% @ %nowdone%
>>c:\scripts\Restartme.log 2>&1 Echo ------------------------------------------------------------------
>>c:\scripts\Restartme.log 2>&1 Echo.
Copy c:\scripts\Restartme.log \\seaapps\apps\logfiles /y[/cpp]
Is this something easy to accomplish!? I appreciate the help from anyone.
--- Charles!
MACHINE1
MACHINE2
MACHINE3
And restartmenames.txt looks like this:
Bob Lastname
Bill Lastname
Jason Lastname
Right now, my log-file writes like this:
.Machine1
.Machine2
.Machine3
What I would like to see, is this:
.Machine1 (Bob Lastname)
.Machine2 (Bill Lastname)
.Machine3 (Jason Lastname)
What I don't know how to do, is call that 2nd file to write the log entries, or if it's even possible. Here is what my code currently looks like:
[cpp]@ECHO OFF
FOR /F "tokens=*" %%A IN ('TIME/T') DO SET Now=%%A
>>c:\scripts\Restartme.log 2>&1 Echo Restarting of machines STARTED on %date% @ %now%
>>c:\scripts\Restartme.log 2>&1 Echo.
set _=c:\scripts\restartmelist.txt
for /f %%i in (
%_%
) do (
>>c:\scripts\Restartme.log 2>&1 SHUTDOWN /r /m \\%%i /t %1 /c "This machine is forcibly restarting in %1 seconds!" /f
>>c:\scripts\Restartme.log 2>&1 Echo . %%i
)
FOR /F "tokens=*" %%B IN ('TIME/T') DO SET NowDone=%%B
>>c:\scripts\Restartme.log 2>&1 Echo.
>>c:\scripts\Restartme.log 2>&1 Echo Restarting of machines COMPLETED on %date% @ %nowdone%
>>c:\scripts\Restartme.log 2>&1 Echo ------------------------------------------------------------------
>>c:\scripts\Restartme.log 2>&1 Echo.
Copy c:\scripts\Restartme.log \\seaapps\apps\logfiles /y[/cpp]
Is this something easy to accomplish!? I appreciate the help from anyone.
--- Charles!