VBScript: Uninstall and Install iTunes (Upgrade) using automatic product code finder script (or any other product, by using product name)

Download “Upgrade_and_Install_blog.coretech.dk.zip” Upgrade_and_Install_blog.ctglobalservices.com_.zip – Downloaded 696 times –

a couple of weeks ago I wrote an article about the new script that enabled the user to find product code automatically from the product have, you can read it here

I promised to do a follow up! explaining how to uninstall, then afterward install iTunes (or any other product), without knowing the version/product code.

By using the function from the other article this is very easily done:

All we have is the product code finder function, and uninstall function, and a log function.

We call the uninstall function sending the productcode as a parameter.

This product code I found by using the GetProductCode function in the same line.

After the uninstall, we install the msi packages again. Using error handling we check if the install is OK (0 = Success, 3010 = success but reboot pending)

otherwise we call the logerror function, which will log the error to the errorlog on the local PC. this means we can after a deployment, connect to the eventlog and read the error messages, if needed.

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (http://mvp.microsoft.com/en-us/default.aspx), Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at https://blog.ctglobalservices.com/jgs

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (www.mmsmoa.com)
  • SCU Europe 2014, 2015, 2016 (www.systemcenteruniverse.ch)
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (www.nic.com)
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (www.techdays.se)
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack


  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops


  1. vern August 29, 2012 at 0:05 - Reply

    Thanks very much for the code – was looking for something like this…one question though

    The code:
    ObjShell.LogEvent 4, “Found Installed “& strName &” product Code: ” & Replace(Replace(strValue, “MsiExec.exe /X”,””), “MsiExec.exe /I”,””)
    If strValue “” Then
    GetProductCode = Replace(Replace(strValue, “MsiExec.exe /X”,””), “MsiExec.exe /I”,””)

    is not returning the full silent uninstall, so then nothing uninstalls. ie msiexec /x {xxxxxxxxx…], I’ve been looking in the event viewer logs and also changed the code to write out to a logfile to make sure. It finds my product but does not uninstall (in my case I’m trying to uninstall adobe reader 9 for a test.


  2. Steve February 25, 2013 at 21:47 - Reply

    I’m trying to adapt this script to uninstall Live Meeting and it does not uninstall anything.

  3. Continúa August 14, 2014 at 18:57 - Reply


    Coretech Blog » Blog Archive » VBScript: Uninstall and Install iTunes (Upgrade) using automatic product code finder script (or any other product, by using product name)

  4. landscaping virginia beach September 15, 2014 at 16:07 - Reply

    Hey! This is kind of off topic but I need some help from an established blog.

    Is it very difficult to set up your own blog? I’m not very techincal
    but I can figure things out pretty fast. I’m thinking about setting
    up my own but I’m not sure where to begin. Do you have any points or suggestions?
    Appreciate it

    my website :: landscaping virginia beach

  5. Stefan October 3, 2014 at 8:30 - Reply

    We deploy iTunes to a lot of peobles and this tool will make it easier. There is a good special script, but does not uninstall my old iTunes-installations. in the Event-viewer find correct string, but does not uninstall. Can you help us? Thanks

  6. […] VBScript : Uninstall and Install iTunes (Upgrade …Home » Jakob Gottlieb Svendsen » VBScript: Uninstall and Install iTunes … “Apple Application Support” Uninstall GetProductCode … Uninstall and Install iTunes …Kan du besøge hjemmesiden […]

  7. We’re a group of volunteers and starting a new scheme in our community.
    Your site offered us with valuable information to work on. You’ve done an impressive job and our
    whole community will be thankful to you.

  8. Ayesha March 31, 2016 at 13:15 - Reply


    I want to uninstall Itunes from multiple computers silently. how can I call this procedure for uninstallation.


    • Jakob Gottlieb Svendsen
      Jakob Gottlieb Svendsen March 31, 2016 at 14:03 - Reply


      this script only works locally.
      you can use systems like system center configuration manager to make it run on each PC. Or you can use scripting tool PowerShell to execute it.

  9. Terje April 3, 2017 at 12:25 - Reply


    What part of the script is needed for only uninstalling the software?


Leave A Comment