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

silent_args = "/S"
app_uninstallkey = "TeamViewer"


def install():
    bin_name = glob.glob("TeamViewer_Setup*.exe")[0]
    install_exe_if_needed(
        bin_name,
        silentflags=silent_args,
        key=app_uninstallkey,
        min_version=control.get_software_version(),
        timeout=900,
    )
    # Disable automatic updates
    registry_setstring(HKEY_LOCAL_MACHINE, r"SOFTWARE\TeamViewer", "AutoUpdateMode", 3, type=REG_DWORD)
    
    # Changing default service start mode of the application
    if control.package.startswith('tis-'):
        set_service_start_mode("TeamViewer", "Manual")
