我在这个FOR循环中度过了最艰难的时光。我认为它有一天工作,但是当我今天去使用它时,却没有。这是一个更大的脚本的一部分,但这是唯一让我感到高兴的部分。另外,要注意,我没有写大部分脚本。这是给了我的,我不得不修改它以满足我的需要。有人可以看看,让我失去我想要的东西。
IF NOT EXIST C:\Paytronix\config\deploytool\terminals.xml (
copy terminals.xml_template terminals.xml > temp.txt
set MAKETERMXML=1
) ELSE (
set MAKETERMXML=0
)
echo Create terminals.xml = %MAKETERMXML%
PING localhost -n 5 >NUL
for /l %%T in (1,1,%TERMINALS%) do (
echo Trying terminal %TERMSTRING%%%T
PING localhost -n 5 >NUL
REM net use /user:USERNAME /PERSISTENT:NO P: \\%TERMSTRING%%%T\C$ PASSWORD
net use P: \\%TERMSTRING%%%T\C$ /USER:%USR% %PWRD% /PERSISTENT:NO > temp.txt
REM /USER:username password (Insert after C$
REM net use P: \\%TERMSTRING%%%T\C$ /PERSISTENT:NO > temp.txt
setlocal EnableDelayedExpansion
echo Copying Installer Shortcut to Startup Folder
IF EXIST "\\%TERMSTRING%%%T\C$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" (
copy aaaPxAlohaUiInstaller.lnk "\\%TERMSTRING%%%T\C$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" > result.txt
) ELSE (
copy aaaPxAlohaUiInstaller.lnk "\\%TERMSTRING%%%T\C$\Documents and Settings\All Users\Start Menu\Programs\Startup" > result.txt
)
PING localhost -n 5 >NUL
find /c "1" result.txt > copyresult.txt
FOR /F "tokens=1,2,3" %%a in (copyresult.txt) do set COPYTAG=%%c
echo Copy Result = !COPYTAG!
PING localhost -n 5 >NUL
IF !COPYTAG!==1 (
echo SUCCESS !!! Valid Terminal %TERMSTRING%%%T > C:\Paytronix\Paytronix.bd
echo SUCCESS !!! Valid Terminal %TERMSTRING%%%T
echo Updating PxInst folder
IF NOT EXIST "\\%TERMSTRING%%%T\C$\PxInst\" mkdir \\%TERMSTRING%%%T\C$\PxInst > temp.txt
REM Delete PxInst contents
del /F /S /Q "\\%TERMSTRING%%%T\C$\PxInst\*" > temp.txt
REM Create PxAlohaUiInstaller folder
IF NOT EXIST "\\%TERMSTRING%%%T\C$\PxInst\PxAlohaUiInstaller" mkdir \\%TERMSTRING%%%T\C$\PxInst\PxAlohaUiInstaller > temp.txt
REM Update user program installer
copy /Y C:\Paytronix\PxAlohaUiInstaller\PxAlohaUiInstaller.exe \\%TERMSTRING%%%T\C$\PxInst\PxAlohaUiInstaller > temp.txt
REM Copy PxAlohaUiInstaller done
PING localhost -n 5 >NUL
REM Create user program dir if missing
IF NOT EXIST "\\%TERMSTRING%%%T\C$\Paytronix" (
echo Creating User Program folder
mkdir \\%TERMSTRING%%%T\C$\Paytronix\config\userprog > temp.txt
copy C:\Paytronix\config\userprog\pxalohaui.cfg \\%TERMSTRING%%%T\C$\Paytronix\config\userprog\ > temp.txt
)
::echo
IF %MAKETERMXML%==1 (
echo ^<Terminal^> >> terminals.xml
echo ^<Name^>term%%T^</Name^> >> terminals.xml
echo ^<Path^>\\%TERMSTRING%%%T\C$^</Path^> >> terminals.xml
echo ^<Address^>%TERMSTRING%%%T^</Address^> >> terminals.xml
echo ^</Terminal^> >> terminals.xml
)
)
endlocal
net use P: /DELETE /YES > temp.txt
del result.txt
del copyresult.txt
del temp.txt
)
echo %MAKETERMXML%
IF %MAKETERMXML%==1 (
echo ^</TerminalList^> >> terminals.xml
echo ^</PaytronixConfig^> >> terminals.xml
copy terminals.xml C:\Paytronix\config\deploytool\terminals.xml
)