/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Uninstall Software Via Batch script

05/04/2017 2931 views
I'm trying to uninstall Saleforce for Outlook Add-on. I'm able to make this work in command line. I'm using /x instead of /I. This works perfect in Command line like I mentioned. 

MsiExec.exe /x{C5E637C6-5AB6-426F-B638-7DC533AE5C75} /qn

However, when I push this out as script in Kace it comes back as failed in the log and does not uninstall off the machine. Any ideas?

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'
1 Comment   [ + ] Show comment

Comments

  • 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.


Community Chosen Answer

2

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.



Answered 05/04/2017 by: mantexau
Blue Belt

  • 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"
    • 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.

All Answers

1

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.

Answered 05/04/2017 by: Drave
Purple Belt

  • 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.
    • 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.
      • 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 "
  • It's been updated the closing " goes before the space before the |
    • 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()
      • Sorry, im mixing my commands with the old cmd syntax. Try that.
    • 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?
      • 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.
      • 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"
    • So I assume then I'm Launching a program under "On Remediation Success"?
      • Correct.
      • Make sure to mark this answer as correct if it solved your issue.
0
Make it a batch file and run it as such from the script. 

Something like

=========================================================================================

@echo off

MsiExec.exe /x{C5E637C6-5AB6-426F-B638-7DC533AE5C75} /qn


exit

============================================================================================
Answered 05/04/2017 by: rockhead44
Red Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ