User Tools

Site Tools


userspace:removemsi

Differences

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

Link to this comparison view

Next revision
Previous revision
userspace:removemsi [2019/10/02 17:03]
tobias created
userspace:removemsi [2021/08/23 08:37] (current)
Line 6: Line 6:
 **NOTE:** \\ **NOTE:** \\
 $result$ must be from Type "StringList"\\ $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 ===== ===== config =====
Line 29: Line 34:
 [2] = All Products uninstalled [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 $result$
 +
 +set $result$ = 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.1570035808.txt.gz ยท Last modified: 2021/08/23 08:37 (external edit)