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

uninstallkey = ["{D273E21E-1119-BF6A-633E-B4C20AA007AE}"]

def install():

    version = control.version.split('-',1)[0]
    cheminDossier = programfiles32 + '\\Scratch2'

    if isrunning('Scratch 2'):
            killalltasks('Scratch 2.exe')

    old_scratch = installed_softwares('scratch')
    if old_scratch:
        for uninstall in old_scratch:
            cmd = WAPT.uninstall_cmd(uninstall['key'])
            print(u'Desinstallation de %s' % (uninstall['name'],))
            run(cmd)

    print('Installation de Scratch %s'%version)
    print run('msiexec /quiet TARGETDIR="%s" /i setup.msi /Lime "%s\\log.txt"'%(cheminDossier, programfiles32))
