Good evening all,
I'm trying to write a batch file (paste 1) that needs to read a list of computers from a text file and ping them to ensure that they are online, and if they are online it needs to copy over a folder located on my desktop to each specific machine on the list. The batch file only writes the following information to the log file (paste 2) and I think that my problem lies in either my variables or my FOR statement. I would greatly appreciate anyone's help in this matter, thanks in advance.
Paste 1:
::This is a batch file that will copy the revised Employee Management databse to a list of computers
CLS
@Echo off
::Create log file
ECHO This is a test of copying log > C
This_is_a_test_of_copying_logfile.txt
::Set Variables
set whack=\
for /f "tokens=1" %%1 in (C
This_is_a_test_list.txt) DO CALL :FILECOPY %%1
:FILECOPY
set pcname=%1%
set UNC=%whack%%whack%%pcname%
::Check target status
Ping –n 1 %1 | find "Reply" > nul
IF %ERRORLEVEL% EQU 1 (
GOTO OFFLINE
) ELSE (
GOTO COPY
)
:COPY
IF EXIST "%UNC%\C$\Program Files\Employee Management" (
COPY /Y "C
Documents and Settings\pptadmsanchezjc\Desktop\Test Copy\*.*" "%UNC%\C$\Program Files\Employee Management\*.*
"ECHO New Employee Management Front End copied on %UNC% >> C
This_is_a_test_of_copying_logfile.txt
GOTO END
) ELSE (
xcopy “C
Documents and Settings\pptadmsanchezjc\Desktop\Test Copy" "%UNC%\C$\Program Files\Employee Management" /i /y /e
IF NOT EXIST "%UNC%\C$\Program Files\Employee Management" ECHO %UNC% was alive but Employee Management did not get copied over >> C
This_is_a_test_of_copying_logfile.txt
)
:OFFLINE
ECHO %1 is offline >> C
This_is_a_test_of_copying_logfile.txt
:END
Paste 2:
This is a test of copying log
PPTTPCTRAIN01 is offline
PPTTPCTRAIN02 is offline
PPTTPCTRAIN03 is offlineis
offline
I'm trying to write a batch file (paste 1) that needs to read a list of computers from a text file and ping them to ensure that they are online, and if they are online it needs to copy over a folder located on my desktop to each specific machine on the list. The batch file only writes the following information to the log file (paste 2) and I think that my problem lies in either my variables or my FOR statement. I would greatly appreciate anyone's help in this matter, thanks in advance.
Paste 1:
::This is a batch file that will copy the revised Employee Management databse to a list of computers
CLS
@Echo off
::Create log file
ECHO This is a test of copying log > C
This_is_a_test_of_copying_logfile.txt::Set Variables
set whack=\
for /f "tokens=1" %%1 in (C
This_is_a_test_list.txt) DO CALL :FILECOPY %%1:FILECOPY
set pcname=%1%
set UNC=%whack%%whack%%pcname%
::Check target status
Ping –n 1 %1 | find "Reply" > nul
IF %ERRORLEVEL% EQU 1 (
GOTO OFFLINE
) ELSE (
GOTO COPY
)
:COPY
IF EXIST "%UNC%\C$\Program Files\Employee Management" (
COPY /Y "C
Documents and Settings\pptadmsanchezjc\Desktop\Test Copy\*.*" "%UNC%\C$\Program Files\Employee Management\*.*"ECHO New Employee Management Front End copied on %UNC% >> C
This_is_a_test_of_copying_logfile.txtGOTO END
) ELSE (
xcopy “C
Documents and Settings\pptadmsanchezjc\Desktop\Test Copy" "%UNC%\C$\Program Files\Employee Management" /i /y /eIF NOT EXIST "%UNC%\C$\Program Files\Employee Management" ECHO %UNC% was alive but Employee Management did not get copied over >> C
This_is_a_test_of_copying_logfile.txt)
:OFFLINE
ECHO %1 is offline >> C
This_is_a_test_of_copying_logfile.txt:END
Paste 2:
This is a test of copying log
PPTTPCTRAIN01 is offline
PPTTPCTRAIN02 is offline
PPTTPCTRAIN03 is offlineis
offline