Hi community stackoverflow,
I am writing a batch file to perform some automatic computer maintenance and have included several anti-virus applications. For some reason, the third statement “if not” is never achieved.
:AV REM MSE if not '%MSE%'=='' ( Echo Scanning for viruses using Microsoft Security Essentials. Echo. %MSE% -Scan -ScanType 1 Echo. GOTO Defrag ) REM AVG if not '%AVG%'=='' ( Echo Scanning for viruses using AVG. Echo. %AVG% /COMP /QT /TRASH Echo. GOTO Defrag ) REM NOD32 if not '%NOD32%'==''( Echo Scanning for viruses using NOD32. Echo. if '%NOD32%'=='' GOTO NOD32NotFound %NOD32% /aind /auto /log-file="%userprofile%\Desktop\Scan_Results.txt" Echo. GOTO Defrag ) REM If all else fails... GOTO AVNotFound
Currently, there are three blocks of codes, one for each antivirus program. Each block of code is executed only when the variable% AVG %% MSE% or% NOD32% is not empty, that is, it points to a valid file. I assign variables using code:
if exist "%programfiles(x86)%\AVG\AVG2012\avgscana.exe" set AVG="%programfiles(x86)%\AVG\AVG2012\avgscana.exe"
All three blocks of code work fine, nothing works with encoding. The problem is that regardless of the third block, it is never executed. So, in the current example, the code blocks are in the order of MSE, AVG, and NOD32. The NOD32 code block is not executed because it is the third block. Conversely, if I cut and paste the blocks in a different order with the AVG code block being the third block, it will not execute.
Any ideas?
Any suggestions?
Edited for clarification.
source share