2012-08-16 97 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