Uninstall Software Via Batch script
Output Log
Running as SYSTEM C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\186>MsiExec.exe /x{C5E637C6-5AB6-426F-B638-7DC533AE5C75} /qn T Creating process returned non-zero: C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\186\kace7027.bat : (0) The operation completed successfully. Error Code: 0 Status Code: 1605
Activity Log
Launching program: 'C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\186\kace7027.bat' '' wait='true'
-
I'm in search of a better answer to this. The issue for me is, the product doesn't exist. However I need it to attempt uninstalling a list of products and move on. When I do install the product, it runs the msiexec /x uninstall fine. - worzie 7 years ago
Answers (3)
Creating a batch file and run it as a script normally does the trick as pointed out by rockhead44. If you are having issues configuring your own script you can also use the Windows Uninstaller option from Configuration Policies. You can find this under Scripting -> Configuration Policies -> Uninstaller
You basically only need to hit the save button and your script is created, I usually fall to this option when my scripts fail to do what I want them to do.
Comments:
-
I did that but that does not work. I made sure it has the right version still. No go. I'm wondering if its because we install salesforce for "just me" instead of the default option which is install salesforce for "Everyone On this computer" - sam240 7 years ago
-
To start troubleshooting I would add the logging option to Parameter field (or to your script if you are using a batch) and then go through the log to see where its failing. I doesn't seem like an issue with the K1000 task, but rather the software you're trying to uninstall. I use the logging option 99% of the time, in case I encounter problems with installations, comes in handy when you have to troubleshoot. example:
/L*V C:\temp\Salesforce_uninstall.log
Where "temp" is the folder which you have allocated for your software package install logs
You could also enable debugging on the K1000 agent, and have a look at the Kagent.log for more detailed info, just so you can rule out an issue with the K1000 task, etc. - mantexau 7 years ago
Top Answer
Use Powershell.
Get-WmiObject -class WIN32_Product -filter "name like '%salesforce%outlook%'" | % { $_.Uninstall()}
I can break this down for you and explain if you want. I did it once already, but the stupid site errored out my post and the whole thing I wrote was lost. Really irritating. Let me know if you want an explanation of how this works.
You can also use this to remove specific versions of software in case multiple instances can coexist for instance, java.
Comments:
-
Hi Dave, Thank you for assistance. So how would you run powershell from Kace? Do you tell a batch file to execute the .ps1 file? Also I tried running your powershell on my machine to uninstall Salesforce for outlook nothing happens, I see >> blinking but stays on that forever. I wonder if I'm missing something. I did run powershell as administrator. - sam240 7 years ago
-
No in scripting you tell KACE to start a program. Then you point the program folder to the folder containing Powershell "C:\Windows\sysnative\WindowsPowershell\v1.0". The program name is "Powershell.exe"
You enter the GET-WmiObject line into the arguments. - Drave 7 years ago-
Thank you! However, I think there are error in your script.
Get-WmiObject -class WIN32_Product -filter "name like '%salesforce%outlook%' | call $_.uninstall
Like for example you started "name but you didn't close this with " - sam240 7 years ago
-
It's been updated the closing " goes before the space before the | - Drave 7 years ago
-
call : The term 'call' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
I did get this to work however since its not in one line I can't use it.
$app = Get-WmiObject -Class Win32_Product | Where-Object {
$_.Name -match “Salesforce for Outlook”
}
$app.Uninstall() - sam240 7 years ago-
Sorry, im mixing my commands with the old cmd syntax. Try that. - Drave 7 years ago
-
Perfect that worked. Now the problem is that to uninstall this, It requires Outlook.exe and SfdcMsOl.exe to be killed otherwise it fails. How would I go about doing that? - sam240 7 years ago
-
Under the "Verify" section select "Verify Process in not running..." Then if the software is running, it will fail so you'll need to put a remediation task to "kill the process"
You'll need to do that for any process that will need to be killed. You may want to warn users about this before the script is run, otherwise this may cause help desk calls. - Drave 7 years ago -
You'll likely want to duplicate any tasks under "On Success" to "On Remediation Success". If you don't then after remediation, nothing will happen. You may also want to set a task under "On Remediation Failure" - Drave 7 years ago
-
So I assume then I'm Launching a program under "On Remediation Success"? - sam240 7 years ago
Something like