User Tools

Site Tools


userspace:removemsi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

userspace:removemsi [2019/10/02 17:43]
tobias [Sample usage in delsub.opsiscript]
userspace:removemsi [2021/08/23 08:37]
Line 1: Line 1:
-====== removeMSI ====== 
  
-**CALL:** 
-<code>set $result$ = removeMSI("dummy")</code> 
- 
-**NOTE:** \\ 
-$result$ must be from Type "StringList"\\ 
- 
-====== Usage ====== 
-Check WINST Manual: \\ 
-[[https://download.uib.de/opsi_stable/doc/html/en/opsi-winst-manual/opsi-winst-manual.html#opsi-winst-commands-localfunctions |9.22. Local functions]] \\ 
-[[https://download.uib.de/opsi_stable/doc/html/en/opsi-winst-manual/opsi-winst-manual.html#opsi-winst-commands-localfunctions|9.23. Import von Library Funktionen]] 
- 
-===== config ===== 
-Create a file named msi.conf in your %ScriptDir% \\ 
-In this file, you have to include all MSIIDs you want to remove in the following format: \\ 
-Desciption of your Software:{your-msi-id}\\ 
-For example: 
-<code>vcredist_x64_2010:{1D8E6291-B0D5-35EC-8441-6616F567A0F7}</code> 
- 
- 
-===== Retrurn StringList ===== 
-You will get the following information back (in case of an error): 
- 
-[0] = Description\\ 
-[1] = ExitCode\\ 
-[2] = Error Desciption (If known, otherwise UNKNOWN)\\ 
- 
- 
-In case of ExitCode 0, 1605, 1641 or 3010 you will only get the following Information back: 
- 
-[0] = All Products uninstalled\\ 
-[1] = 0\\ 
-[2] = All Products uninstalled 
- 
-===== CODE ===== 
-<code> 
-DefFunc RemoveMSI(val $remove$ : string) : stringlist 
- DefStringList $msiidsAndDescription$ 
- DefStringList $transformList$ 
- DefVar $ID$ 
- DefVar $description$ 
- DefVar $ExitCode$ 
-  
- set $msiidsAndDescription$ = loadTextFile ("%scriptpath%\msi.conf") 
-  
- for %i% in $msiidsAndDescription$ do sub_extract_id_and_description 
-  
- [sub_extract_id_and_description]  
- set $transformList$ = splitstring("%i%",":") 
-  
- set $Description$ = takestring(0,$transformList$) 
- set $ID$ = takestring(1,$transformList$) 
- set $transformList$ = emptylist($transformList$) 
- 
- Message "remove "+$Description$ 
-  
-  
- if not (GetRegistryStringValue32("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $ID$ + "] DisplayName") = "") 
- comment "MSI id " + $ID$ + " found in registry, starting msiexec to uninstall" 
- Winbatch_uninstall_msi 
- sub_check_exitcode 
- endif 
-  
- if not (GetRegistryStringValue64("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $ID$ + "] DisplayName") = "") 
- comment "MSI id " + $ID + " found in registry, starting msiexec to uninstall" 
- Winbatch_uninstall_msi 
- sub_check_exitcode 
- endif 
-  
-  
- [Winbatch_uninstall_msi] 
- msiexec /x $ID$ /qb-! REBOOT=ReallySuppress 
-  
- [sub_check_exitcode] 
- set $ExitCode$ = getLastExitCode 
- 
- Switch $ExitCode$ 
-        Case "0" 
-               comment "Looks good: setup program gives exitcode zero" 
-               set $result$ = emptylist($result$) 
-               set $result$ = addToList($result$,"All Products uninstalled") 
-               set $result$ = addToList($result$,"0") 
-               set $result$ = addToList($result$,"All Products uninstalled") 
-        EndCase 
-        case "1605" 
-          set $result$ = addToList($result$,$Description$) 
-                set $result$ = addToList($result$,$ExitCode$) 
-                set $result$ = addToList($result$,"ERROR_UNKNOWN_PRODUCT 1605 This action is only valid for products that are currently installed") 
- EndCase 
- case "1641" 
-          set $result$ = addToList($result$,$Description$) 
-                set $result$ = addToList($result$,$ExitCode$) 
-                set $result$ = addToList($result$,"ERROR_SUCCESS_REBOOT_INITIATED 1641 The installer has initiated a restart. This message is indicative of a success.") 
- EndCase 
- case "3010" 
-          set $result$ = addToList($result$,$Description$) 
-                set $result$ = addToList($result$,$ExitCode$) 
-                set $result$ = addToList($result$,"ERROR_SUCCESS_REBOOT_REQUIRED 3010 A restart is required to complete the install. This message is indicative of a success.") 
- EndCase 
-        DefaultCase 
-        Message $exitcode$ 
-                set $result$ = addToList($result$,$Description$) 
-                set $result$ = addToList($result$,$ExitCode$) 
-                set $result$ = addToList($result$,"UNKNOWN") 
-                isFatalError 
-        EndCase 
-     EndSwitch 
-EndFunc 
-  
- 
-</code> 
- 
-===== Sample usage in delsub.opsiscript ===== 
-All MSI Software Packages defined in the msi.conf file will be removed. 
- 
-<code> 
-importLib "removeMSI.opsiinc" 
-DefStringList $dummy$ 
- 
-set $dummy$ = removeMSI("dummy") 
-</code> 
- 
-===== Questions, bug reports, feature request, or just an idea for new crazy functions ??? ===== 
-This Function is Part of my OPSI-WINST-LIBRARY Bundle, which home is on GitHUB.\\ 
-Feel free to share your Ideas for new functions or contact me there for bug reports. \\ 
-[[https://github.com/Venice-89/OPSI-WINST-Library|OPSI-WINST-Library on GitHUB]] 
userspace/removemsi.txt ยท Last modified: 2021/08/23 08:37 (external edit)