How to enable/disable the windows defender in C++

shines7 41 Reputation points
2022-01-18T07:07:24.567+00:00

I have turned off real-time protection of windows defender and turned it on.
And I checked the status value with "Get-MpPreference -verbose" with powershell.
It was confirmed that the value of "DisableRealtimeMoniotring" was changed to True/False.
I tried "Set-MpPreference -DisableRealtimeMoniotring $false/$true"
In this case, the state value has not changed.

I want to know the activation status value of windows defender.
I want to enable/disable windows defender.
How to do it in c++/powershell or etc?
The best is C++.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,631 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,530 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. YujianYao-MSFT 4,271 Reputation points Microsoft Vendor
    2022-01-19T02:09:42.623+00:00

    Hi @shines7 ,

    I suggest you to read the document of WDEnable and WDStatus which are able to enable/disable Windows Defender and view the status of Windows Defender.

    Note:

    WDEnable is no longer available for use as of Windows 10, version 1607.

    Beginning in Windows 10, version 1607 and Windows Server 2016, the WDEnable function always returns E_NOTIMPL.

    Best regards,

    Elya


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. S.Sengupta 15,191 Reputation points MVP
    2022-01-27T12:37:49.187+00:00
    0 comments No comments