2012-08-16 101 views
0

我正在编写需要停止的批处理脚本,然后在中间启动AVG防病毒保护。 有没有办法只使用命令行?如何从命令行停止/启动AVG防病毒保护

+0

当你说“在中间”时,你是什么意思?我假设你说“停止”是指退出应用程序。真正?是否有一些事件要用于触发停止,或者仅仅是用户的选择?同样的问题开始。 – David 2012-08-16 19:12:37

+0

嗨大卫,你的回应10倍。我的脚本执行一些命令,然后我需要停止AVG,执行一些命令,然后再次启动AVG。我的脚本正在使用CPU和内存的负载,我需要停止所有背景消耗程序。 – SharonBL 2012-08-17 06:52:13

+0

在AVG中,可以选择“临时禁用保护”,这会让应用程序本身继续运行。您是否尝试切换此选项或完全终止应用程序? – 2012-08-17 17:44:42

回答

1

好的 - 我想你想看起来像这样的东西。这不是防弹的,但它应该让你开始。

Set myshell = WScript.CreateObject("WScript.Shell") 
Dim cmd 

REM Do your pre-AVG-stop commands here 

REM Now stop AVG using the 'taskkill' command. Note that this command assumes 
REM that the name of the process is "avgscanx". You should verify that is true. 
REM You also may need to play around with the parameters for 'taskkill'. Run 
REM 'taskkilll /?' in a cmd window to see the various options. You may also want 
REM to add some code to verify that taskkill was successful. 

taskkill /IM "avgscanx" 

REM Do your post-AVG-stop commands here. 

REM Now, let's restart AVG. 
REM Modify the command line below for your specific use of AVG. 
REM And, again, you may want to add some code to verify that AVG started. 

cmd = """avgscanx"" /parameter1 /parameter2 /etc" 
myshell.Run(cmd,0,true) 

最后一个注意事项。您可能需要考虑切换到PowerShell,因为它比批处理更强大,更灵活。

+0

10x David。我尝试使用av​​g进程在命令taskill之前 - 它拒绝停止。此外 - 我试图将服务更改为手动,然后停止它 - 它也失败了。似乎所有常规选项都被阻止:-( – SharonBL 2012-08-19 06:29:52

+0

您是否确认进程的名称是“avgscanx”?这仅仅是我的猜测,基于阅读AVG帮助文档。您还可以尝试'taskkill/F/IM“avgscanx”/ T'这是一个更具侵略性的东西,而且AVG是在你的脚本的相同用户凭据下运行的吗?如果不是,那么你需要考虑一些额外的参数来“taskkill”。 – David 2012-08-20 21:25:44