I have to uninstall many products one after one and to respect an order. How can i do this en command line


Answer Summary:
3 Comments   [ - ] Hide Comments


  • What deployment tool are you using? You should take advantage of that instead of using a batch file.
  • i'm using sccm to deploy my application
  • So build a Task Sequence. Although these were designed for OS deployment, they're ideal for this kind of thing.
Please log in to comment

Community Chosen Answer



Build a script and add the uninstallation command lines for each application in exact order you want.

Here is an example:

 Option Explicit

Dim strScriptPath : strScriptPath = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\")-1)
Dim objWSH

Set objWSH = CreateObject("WScript.Shell")

if MSIInstalled("{31E11496-1F84-4DCC-B07A-369B40B8B4A7}") then
objWSH.Run "msiexec /x {31E11496-1F84-4DCC-B07A-369B40B8B4A7} /qn",,True
end if

if MSIInstalled("{CCA40624-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40624-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{3186ACD0-B5C5-470E-ABE1-E4110C0A72BF}") then
objWSH.Run "msiexec /x {3186ACD0-B5C5-470E-ABE1-E4110C0A72BF} /qn",,True
end if

if MSIInstalled("{CCA40692-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40692-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40628-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40628-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40629-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40629-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40631-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40631-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40637-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40637-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40676-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40676-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40678-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40678-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40630-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40630-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40632-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40632-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40656-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40656-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40675-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40675-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

if MSIInstalled("{CCA40679-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40679-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

'Chinese (Traditional)
if MSIInstalled("{CCA40687-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40687-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

'Chinese (Simplified)
if MSIInstalled("{CCA40689-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40689-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

'Estonian (English)
if MSIInstalled("{CCA40602-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40602-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

'Dutch Netherlands
if MSIInstalled("{CCA40623-843E-48C6-B14F-E1070015D87C}") then
objWSH.Run "msiexec /x {CCA40623-843E-48C6-B14F-E1070015D87C} /qn",,True
end if

Function MSIInstalled(strProductCode)
Dim colList
Dim strItem
Dim objWI
Set objWI = CreateObject("WindowsInstaller.Installer")

For Each strItem In objWI.Products
If UCase(strProductCode) = UCase(strItem) Then
MSIInstalled = True
Exit Function
End If
MSIInstalled = False
End Function

The script is verifing for each msi if is installed or not and if is installed them will uninstall it.

Answered 06/06/2013 by: terebent
Second Degree Brown Belt

  • Thanks for answers
Please log in to comment
Answer this question or Comment on this question for clarity



If you are using a K1000, you can use the Scripting module to build in logic into your tasks so that you can do them in order.  You can check out some KKEs on Scripting at our recordings page:


Answered 06/03/2013 by: andrew_lubchansky
Black Belt

Please log in to comment