.. Reminder for header structure:
  Parts (H1)          : #################### with overline
  Chapters (H2)       : ******************** with overline
  Sections (H3)       : ====================
  Subsections (H4)    : --------------------
  Subsubsections (H5) : ^^^^^^^^^^^^^^^^^^^^
  Paragraphs (H6)     : """""""""""""""""""""

.. meta::
  :description: Uninstalling the WAPT Agent from clients
  :keywords: WAPT, documentation, uninstalling

.. _uninstall_waptagent_linux:

########################################
Uninstalling the WAPT Agent from clients
########################################

*******
Windows
*******

If you need to uninstall the WAPT Agent from computers, the uninstaller is automatically created in the WAPT install location.
By default the uninstaller is locatedin :file:`C:\\Program Files (x86)\\wapt\\unins000.exe`.

* A default silent uninstall of a WAPT Agent can be achieved with the following command.

.. code-block:: bash

  unins000.exe /VERYSILENT

* An additional argument can be passed to :command:`unins000.exe` to cleanup everything.

.. code-block:: bash

  unins000.exe /VERYSILENT /purge_wapt_dir=1

.. list-table:: Complete list of command-line arguments for :command:`unins000.exe`
  :header-rows: 1
  :widths: auto
  :align: center

  * - Settings
    - Description
  * - :code:`/VERYSILENT`
    - Launches :program:`unins000.exe` silently.
  * - :code:`/purge_wapt_dir` = ``True``
    - Purges the WAPT directory (removes all folders and files).

* It is possible to use a WAPT package to achieve the same result.

.. code-block:: python

  # -*- coding: utf-8 -*-
  from setuphelpers import *

  def install():

    print("Creation of the task")
    task = create_onetime_task('removewapt', "unins000.exe", "/VERYSILENT /purge_wapt_dir = True")
    print(task)

* It is also possible to use a scheduled task to run the following command.

.. code-block:: bash

  unins000.exe /VERYSILENT /purge_wapt_dir=1

Re-enabling Windows Updates before uninstalling |enterprise_feature|
====================================================================

In the case you have used WAPT to manage Windows Updates, you might want to re-enable Windows Updates default behavior before uninstalling the WAPT Agent.

To do so, here is an example WAPT package to push before uninstalling the WAPT Agent:

.. code-block:: python

  # -*- coding: utf-8 -*-
  from setuphelpers import *

  def install():
    print('Disable WAPT WUA')
    inifile_writestring(WAPT.config_filename,'waptwua','enabled','false')

    print('DisableWindowsUpdateAccess registry to 0')
    registry_set(HKEY_LOCAL_MACHINE,r'Software\Policies\Microsoft\Windows\WindowsUpdate','DisableWindowsUpdateAccess',0,REG_DWORD)

    print('AUOptions registry to 0')
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update','AUOptions',0,REG_DWORD)

    print('Enable wuauserv')
    run_notfatal('sc config wuauserv start= auto')
    run_notfatal('net start wuauserv')

    print('Reload WAPT configuration')
    WAPT.reload_config_if_updated()

*****
Linux
*****

* The default uninstall of a WAPT Agent can be achieved with the following command, depending on your Linux distribution:

.. tabs::

  .. code-tab:: bash Debian and derivatives

    apt remove --purge tis-waptagent

  .. code-tab:: bash RedHat and derivatives

    yum remove tis-waptagent

* An additional step can be done using these commands (WIP).

.. tabs::

  .. code-tab:: bash Debian and derivatives

    rm -f /opt/wapt/
    rm /etc/apt/sources.list.d/wapt.list

  .. code-tab:: bash RedHat and derivatives

    rm -f /opt/wapt/
    rm /etc/yum/yum.repos.d/wapt.list

*****
macOS
*****

The default uninstall of a WAPT Agent can be achieved with the following command:

.. code-block:: bash

  pkgutil --only-files --files it.tranquil.waptservice > file_list
  sudo pkgutil --forget it.tranquil.waptservice
