좋아요, 그래서 클라이언트의 파일을 대체하여 클라이언트 마이그레이션을 돕기 위해 배치 파일을 작성하고 있습니다. 올바른 코드 현명한 그러나 내가 그것을 뛰어 넘고 싶은FOR 및 IF 존재 및 고토 문제가있는 Windows 일괄 처리
ECHO Could not find SEP on client %%v
ECHO %%v >> %LIST%%N2%
이된다
@ECHO OFF
ECHO Only type "clients" or "servers"
SET /P TYPE=clients or servers:
SET /P LIST=%TYPE% list filename:
SET /P SITE=Site:
SET SYMPATH=""
SET LIST2=""
SET N=
SET N2=0
Echo This will migrate %TYPE% in site %SITE% from list %LIST%, correct?
PAUSE
:STRT
SET /a N2=N2+1
SET LIST2=%LIST%%N%
FOR /F "tokens=*" %%v IN (%LIST2%) DO (
ECHO Checking %%v...
SET COMP=%%v
if exist "\\%%v\c$\program files (x86)\symantec\symantec endpoint protection\smc.exe" SET "SYMPATH=program files (x86)\symantec\symantec endpoint protection" & CALL :MIGRATE
if exist "\\%%v\c$\program files\symantec\symantec endpoint protection\smc.exe" SET "SYMPATH=program files\symantec\symantec endpoint protection" & CALL :MIGRATE
if exist "\\%%v\c$\program files (x86)\symantec antivirus\smc.exe" SET "SYMPATH=program files (x86)\symantec antivirus" & CALL :MIGRATE
if exist "\\%%v\c$\program files\symantec antivirus\smc.exe" SET "SYMPATH=program files\symantec antivirus" & CALL :MIGRATE
ECHO Could not find SEP on client %%v
ECHO %%v >> %LIST%%N2%
)
:MIGRATE
ECHO Migrating %COMP%...
psexec \\%COMP% -h "c:\%SYMPATH%\smc.exe" -p xxxxxx -stop
copy "%TYPE%_xml\My Company_Workplace_%TYPE%_%SITE%_sylink.xml" "\\%COMP%\c$\%SYMPATH%\SyLink.xml" /Y
psexec \\%COMP% -h "c:\%SYMPATH%\smc.exe" -start
ECHO Migrated %COMP% to SEP12 group %SITE% >> END_%SITE%.log
ECHO Migrated %COMP% to SEP12 group %SITE%
EXIT /b
SET /a N=N+1
ECHO End of the list, starting over with %LIST2%
GOTO STRT `
대부분의 일을 제외하고 일하는 클라이언트는 CALL로 다시 이동하고 코드를 실행 마이그레이션 한 후 이 2 개 라인과 같이, 다음 클라이언트를 계속 :
@ECHO OFF
ECHO Only type "clients" or "servers"
SET /P TYPE=clients or servers:
SET /P LIST=%TYPE% list filename:
SET /P SITE=Site:
SET SYMPATH=""
SET LIST2=""
SET N=
SET N2=0
Echo This will migrate %TYPE% in site %SITE% from list %LIST%, correct?
PAUSE
:STRT
SET /a N2=N2+1
SET LIST2=%LIST%%N%
FOR /F "tokens=*" %%v IN (%LIST2%) DO (
ECHO Checking %%v...
SET COMP=%%v
if exist "\\%%v\c$\program files (x86)\symantec\symantec endpoint protection\smc.exe" SET "SYMPATH=program files (x86)\symantec\symantec endpoint protection" & CALL :MIGRATE **& GOTO :NEXT**
if exist "\\%%v\c$\program files\symantec\symantec endpoint protection\smc.exe" SET "SYMPATH=program files\symantec\symantec endpoint protection" & CALL :MIGRATE **& GOTO :NEXT**
if exist "\\%%v\c$\program files (x86)\symantec antivirus\smc.exe" SET "SYMPATH=program files (x86)\symantec antivirus" & CALL :MIGRATE **& GOTO :NEXT**
if exist "\\%%v\c$\program files\symantec antivirus\smc.exe" SET "SYMPATH=program files\symantec antivirus" & CALL :MIGRATE **& GOTO :NEXT**
ECHO Could not find SEP on client %%v
ECHO %%v >> %LIST%%N2%
**:NEXT**
)
:MIGRATE
ECHO Migrating %COMP%...
psexec \\%COMP% -h "c:\%SYMPATH%\smc.exe" -p xxxxxx -stop
copy "%TYPE%_xml\My Company_Workplace_%TYPE%_%SITE%_sylink.xml" "\\%COMP%\c$\%SYMPATH%\SyLink.xml" /Y
psexec \\%COMP% -h "c:\%SYMPATH%\smc.exe" -start
ECHO Migrated %COMP% to SEP12 group %SITE% >> END_%SITE%.log
ECHO Migrated %COMP% to SEP12 group %SITE%
EXIT /b
SET /a N=N+1
ECHO End of the list, starting over with %LIST2%
GOTO STRT `
을하지만 난 (코드 블록에서 GOTO 라벨을 사용할 수 없기 때문에이 작동하지 않습니다)
그래서 누구나 아이디어가 있습니까?
고마워요! 마지막으로 테스트 해 보니 솔루션이 작동합니다! –