Share via

Uninstall programs using batch file(Mainly antivirus)

Anonymous
2019-03-07T11:53:31+00:00

I am trying to write a batch file to find antivirus installed on Windows 7,8,10. 

The need is like the project is trying to change firewall rules as per requirement for client machines.

The clients who are windows machines should have a firewall configured with certain rules. 

I get the error as the firewall is managed by antivirus software. To uninstall I have written the following:

@echo off

setlocal enabledelayedexpansion

    set "i=0"

    for /F "delims=" %%f in ('wmic /node:localhost /namespace:\root\SecurityCenter2 path AntiVirusProduct Get DisplayName ^| findstr /V /B /C:displayName ^| findstr /V /R /C:"^[  ]*$"') do (

      set arr[!i!]=%%f

      set /a "i+=1"

    )

    set arr

    set "len=!i!"

    set "i=1"

:loop

    echo !arr[%i%]!

    wmic product where "description='!arr[%i%]'" uninstall

    set /a "i+=1"

    if %i% neq %len% (

      goto:loop

    )

endlocal

But this is not working.

Can somebody help me how to do it(for any antivirus)?

Windows for home | Windows 10 | Install and upgrade

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2019-03-07T13:25:11+00:00

    Hi, Amarjeet,

    I am an Independent Advisor and will assist you.

    Re-post this question to the Scripting Forum. These Experts create scripts of all types and will be best able to assist you.

    Just click the Ask a Question button.

    https://social.technet.microsoft.com/Forums/en-...

    Pat

    Was this answer helpful?

    0 comments No comments