So I am writing a script that will be deployed through a KACE device in order to install dell updates to our machines. I have the update portion to the point it will work but when I try to input the logic to determine if it is the 2nd Tuesday of the month in order to apply hardware updates along with the logic to determine if a log file is greater than 45 KB in order to determine if anything was installed and reboot the system.
When I combine everything where it is intended to go, I end up getting the error that ( is unexpected. I have looked throughout my code and I am not seeing where the issue is coming from. Can anyone tell me where I have messed up my code so I am able to get this up and running and into production?
@echo off
:: Formatting Date and Time
for /f "tokens=1-4 delims=/ " %%d in ('echo %date%') do (
set dow=%%d
set month=%%e
set day=%%f
set year=%%g
)
pause
:: Picking the 2nd Tuesday
if "%dow%"=="Tue" (
if %day% geq 8 if %day% leq 14 (
cd %windir%\Sysnative
manage-bde.exe -protectors -disable c:
cd "%PROGRAMFILES(X86)%\Dell\CommandUpdate\"
dcu-cli.exe -policy \\server\dell_updates\Policy.xml -log C:\Temp\%COMPUTERNAME%
pause
net use O: \\server\Logs$
cd O:
mkdir O:\%COMPUTERNAME%
del O:\%COMPUTERNAME%\*.xml /s /q
copy C:\Temp\%COMPUTERNAME%\*.* O:\%COMPUTERNAME%
setlocal
set maxbytesize=40000
set file="C:\Temp\%COMPUTERNAME%\ActivityLog.xml"
FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA
if %size% LSS %maxbytesize% (
rmdir c:\temp\%COMPUTERNAME% /s /q
net use o: /delete
endlocal
goto end
)
ELSE (
rmdir c:\temp\%COMPUTERNAME% /s /q
net use o: /delete
cd %windir%\Sysnative
msg.exe * /w /time:0 "Do not press the OK button until you have closed all of your open programs and saved your work. Pressing OK WILL reboot your computer."
c:\windows\system32\shutdown.exe -r -f
endlocal
goto end
)
)
)
:: add the command lines that you want to run on any other day than the 2nd and 4th Monday
pause
:end