Il faut d'abord créer une image administrative depuis les sources d'installation de SolidWorks et copier le dossier de cette image dans le paquet wapt. (https://help.solidworks.com/2019/Englis ... deploy.htm)
On ne peut pas utiliser la commande "startswinstall.exe /uninstall" dans la fonction uninstall() car les sources ne sont plus accessibles à ce moment là.
L'ordre de désinstallation des dépendances dans la fonction uninstall() n'est pas laissé au hasard.
Code : Tout sélectionner
# -*- coding: utf-8 -*-
from setuphelpers import *
def install():
print('Installing: %s' % control.name)
install_exe_if_needed(r'SOLIDWORKS 2022 SP3.1\startswinstall.exe',silentflags='/install /now',timeout=900)
def uninstall():
# Remove software and all dependances installed by my custom Administrative SolidWorks Image. You should probably adapt this function to your Administrative Image.
print('Uninstalling SOLIDWORKS Flow Simulation 2022 SP03.1')
run(r'"MsiExec.exe" /X{A9F14961-697D-455C-B48B-FCE9E22664A5} /passive') # SOLIDWORKS Flow Simulation 2022 SP03.1
print('Uninstalling SOLIDWORKS eDrawings 2022 SP03.1')
run(r'"MsiExec.exe" /X{08A73D4E-3FD0-4242-B08F-A41D8969C5B4} /qb') # SOLIDWORKS eDrawings 2022 SP03.1
print('Uninstalling SOLIDWORKS 2022 French Resources')
run(r'"MsiExec.exe" /X{EBFF07B4-D9ED-4395-B6C7-D83C44FF2216} /qb') # SOLIDWORKS 2022 French Resources
print('Uninstalling Bonjour')
run(r'"MsiExec.exe" /X{6E3610B2-430D-4EB0-81E3-2B57E8B9DE8D} /qb') # Bonjour
print('Uninstalling WPTx64')
run(r'"MsiExec.exe" /X{0B2C58EB-67A2-225B-60B2-D1990E55DD33} /qb') # WPTx64
print('Uninstalling Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219')
run(r'"MsiExec.exe" /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7} /qb') # Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219
print('Uninstalling Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219')
run(r'"MsiExec.exe" /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5} /qb') # Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219
print('Uninstalling Microsoft Visual Studio Tools for Applications 2015')
run(r'"C:\ProgramData\Package Cache\{ab213ab7-4792-4c6f-a3fa-8485d06c3475}\vsta_setup.exe" /uninstall /S') # Microsoft Visual Studio Tools for Applications 2015
print('uninstalling: %s' % control.package)
run(r'"MsiExec.exe" /X{26EA0056-4BAD-4F9E-BDCE-A72E25C7D06D} /passive') # SOLIDWORKS 2022 SP03.1
print('Uninstalling SolidWorks Installation Manager')
if reg_key_exists(HKEY_LOCAL_MACHINE,r'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\SolidWorks Installation Manager 20220-40301-1100-100'):
registry_deletekey(HKEY_LOCAL_MACHINE,r'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall',r'SolidWorks Installation Manager 20220-40301-1100-100')
remove_tree(r'C:\Windows\Solidworks')
print('Remove extra folders and data')
remove_tree(r'C:\Program Files\SOLIDWORKS Corp')
remove_tree(r'C:\SOLIDWORKS Data')
remove_tree(r'C:\ProgramData\SOLIDWORKS')
Pour aller plus loin, il pourrait être pertinent de séparer tous les modules installés par l'image administrative dans des paquets wapt différents... (https://help.solidworks.com/2022/englis ... d_line.htm)