批处理文件第三个“如果不是"声明未达成 [英] Batch Files third "If NOT" statement not reached

查看:57
本文介绍了批处理文件第三个“如果不是"声明未达成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello stackoverflow社区,

Hello stackoverflow community,

我正在编写一个批处理文件来进行一些自动计算机维护,并且其中包含一些防病毒应用程序.由于某些原因,永远不会到达第三个如果不是"的语句.

I am writing a batch file to do some automatic computer maintenance and have included several antivirus applications. For some reason, the third "if not" statement is never reached.

: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

当前,有三个代码块,每个防病毒程序一个.仅当变量%AVG%%MSE%或%NOD32%不为空时才执行每个代码块,这意味着它们指向有效文件.我使用代码分配变量:

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, meaning they point to a valid file. I assign the variables using the code:

if exist "%programfiles(x86)%\AVG\AVG2012\avgscana.exe" set AVG="%programfiles(x86)%\AVG\AVG2012\avgscana.exe"

所有三个代码块都可以正常工作,编码没错.问题在于,无论第三个块是什么,它都永远不会执行.因此,在当前示例中,代码块的顺序为MSE,AVG和NOD32. NOD32的代码块不执行,因为它是第三个代码块.相反,如果我以AVG的代码块为第三块的方式将这些块剪切并粘贴到另一个顺序中,它将无法执行.

All three blocks of code works perfectly, nothing is wrong with the coding. The problem is that whatever the third block is, it never executes. So in the current example, the blocks of code go in the order of MSE, AVG, and NOD32. NOD32's block of code does not execute because it's the third block. Conversely, if I cut and paste the blocks into another order with AVG's block of code being the third block, it would not execute.

有什么想法吗?

有什么建议吗?

为澄清起见而编辑.

推荐答案

您在该行中缺少空格:

if not '%NOD32%'==''(

尝试:

if not '%NOD32%'=='' (

当我尝试脚本时,此行导致失败.更改线后,它起作用了.

When I tried the script this line caused a failure. After changing the line, it worked.

这篇关于批处理文件第三个“如果不是"声明未达成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆