none
Questions about uninstalling software via GPO

    Question

  • We need to uninstall any old versions of some software that is being replaced with a new version.  The new software does not uninstall the old version as part of its installation, so we need to remove manually and we don't have SCCM.  The software was not originally installed via GPO, so we cannot have it automatically removed by removing a GPO.

    We can remove the software with msiexec /x /qn commands manually, so we would like to add it to a startup script.

    None of the computers would have both of these.  It would be one or the other and if either is installed, we need to remove it.

    msiexec /x {XXXXX-XXXX-XXXX} /qn

    msiexec /x {YYYYY-YYYY-YYYY} /qn

    Would we need to do more than just add both those commands to a startup script uninstallapplication.bat  GPO?

    What's the best way to do this so it uninstalls the software if it exists and does not keep trying to uninstall it again if has already done it before.

    We want to avoid adding unnecessary startup delays to computers that have already had the software removed.

    I suppose a more sophisticated script could check for the existence of the software first before attempting to uninstall, but wouldn't that query check in itself add to the startup delays every time the computers are rebooted?

    Is a startup script the best option for software uninstallation?





    • Edited by MyGposts Friday, June 15, 2012 12:49 AM
    Friday, June 15, 2012 12:40 AM

Answers

  •  
    > msiexec /x {XXXXX-XXXX-XXXX} /qn
    >
    > msiexec /x {YYYYY-YYYY-YYYY} /qn
    >
    >
     
    Most software has some files somewhere, so try:
     
    if exist "%programfiles%\xxxx\xxxxmain.exe" msiexec /x {XXXXX-XXXX-XXXX} /qn
    Or:
    reg query
    hklm\software\microsoft\windows\currentversion\uninstall\{XXXXX-XXXX-XXXX}
    && msiexec /x {XXXXX-XXXX-XXXX} /qn
     
    regards, Martin
     

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!
    • Marked as answer by MyGposts Wednesday, June 20, 2012 6:47 PM
    Friday, June 15, 2012 2:55 PM
  • Hi,

    > When I'm logged in as a user and run the bat file manually, the uninstall is complete. However, when I run
    > it as a startup script GPO, it uninstalls the software, but leaves behind the empty program directory folder
    > under C:]Programs as well as (now broken) shortcuts in the start menu and an empty program group in
    > the All Programs menu.

    When you run the script manually, you run it in user context. When run the script in startup policy, it run in system context. Some variable may not available in system context, so some path may not remove successfully.

    You can modify your script to remove these paths, just like:

    Rd /s /q “c:\Documents and settings\All users\Start Menu\Programs\xxyy”

    For more information please refer to following MS articles:

    Rd command
    http://technet.microsoft.com/en-us/library/cc726055(v=WS.10).aspx
    System and Startup Settings
    http://technet.microsoft.com/en-us/library/bb742541.aspx


    Lawrence

    TechNet Community Support

    • Marked as answer by MyGposts Wednesday, June 20, 2012 6:47 PM
    Monday, June 18, 2012 7:50 AM
    Moderator
  •  
    > Are there generic variables for the all users start menu and all users
    > all programs menu that will work for XP and Windows 7 32 and 64?
     
    No - both are "Special Folders" that can be retrieved through operating
    system calls. And of course, you can implement a GPP Environment Item
    that is able to retrieve these special folders (press F3...) and put
    them in environment variables...
     

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!
    • Marked as answer by MyGposts Wednesday, June 20, 2012 6:47 PM
    Wednesday, June 20, 2012 1:40 PM

All replies

  •  
    > msiexec /x {XXXXX-XXXX-XXXX} /qn
    >
    > msiexec /x {YYYYY-YYYY-YYYY} /qn
    >
    >
     
    Most software has some files somewhere, so try:
     
    if exist "%programfiles%\xxxx\xxxxmain.exe" msiexec /x {XXXXX-XXXX-XXXX} /qn
    Or:
    reg query
    hklm\software\microsoft\windows\currentversion\uninstall\{XXXXX-XXXX-XXXX}
    && msiexec /x {XXXXX-XXXX-XXXX} /qn
     
    regards, Martin
     

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!
    • Marked as answer by MyGposts Wednesday, June 20, 2012 6:47 PM
    Friday, June 15, 2012 2:55 PM
  • Won't that keep doing that check for every computer at every reboot?  

    I need it to do it once and not slow down the startup process for the same computers over and over.  Can that be done?

    Friday, June 15, 2012 3:12 PM
  • I tried the uninstall bat file and it works, but there is an odd problem.

    When I'm logged in as a user and run the bat file manually, the uninstall is complete.  However, when I run it as a startup script GPO, it uninstalls the software, but leaves behind the empty program directory folder  under C:]Programs as well as (now broken) shortcuts in the start menu and an empty program group in the All Programs menu.

    Lots of trash left behind and the leftover broken shortcuts will just confuse users.  Is there anything that can be done to get the same result when running manually and when using a GPO startup script? 


    • Edited by MyGposts Friday, June 15, 2012 11:43 PM
    Friday, June 15, 2012 11:41 PM
  • Won't that keep doing that check for every computer at every reboot?  

    I need it to do it once and not slow down the startup process for the same computers over and over.  Can that be done?

    Hi,

    No. By default, Client Side Extension processes this GPO only once if the policy has not changed.

    However, you can modify this default behavior through enable “Process even if the Group Policy objects have not changed” in Group Policy Computer Configuration\Administrative Templates\System\Group Policy\ Scripts policy processing

    For more information please refer to following MS articles:

    Scripts policy processing
    http://technet.microsoft.com/en-us/library/cc978930.aspx


    Lawrence

    TechNet Community Support

    Monday, June 18, 2012 7:42 AM
    Moderator
  • Hi,

    > When I'm logged in as a user and run the bat file manually, the uninstall is complete. However, when I run
    > it as a startup script GPO, it uninstalls the software, but leaves behind the empty program directory folder
    > under C:]Programs as well as (now broken) shortcuts in the start menu and an empty program group in
    > the All Programs menu.

    When you run the script manually, you run it in user context. When run the script in startup policy, it run in system context. Some variable may not available in system context, so some path may not remove successfully.

    You can modify your script to remove these paths, just like:

    Rd /s /q “c:\Documents and settings\All users\Start Menu\Programs\xxyy”

    For more information please refer to following MS articles:

    Rd command
    http://technet.microsoft.com/en-us/library/cc726055(v=WS.10).aspx
    System and Startup Settings
    http://technet.microsoft.com/en-us/library/bb742541.aspx


    Lawrence

    TechNet Community Support

    • Marked as answer by MyGposts Wednesday, June 20, 2012 6:47 PM
    Monday, June 18, 2012 7:50 AM
    Moderator
  •  
    > Won't that keep doing that check for every computer at every reboot?
    >
     
    Yes - but how long does a "dir xyz" usually take? So this doesn't matter...
     

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!
    Monday, June 18, 2012 11:51 AM
  •  
    > Lots of trash left behind and the leftover broken shortcuts will just
    > confuse users.  Is there anything that can be done to get the same
    > result when running manually and when using a GPO startup script?
     Bad installer... This usually happens when
     
    a) the software was initially installed for the current user OR
    b) the software uses ActiveSetup or advertised shortcuts to configure
    something in the users's profile/start menu
     
    Delete the orphaned files through a logon script (same "if exist xyz" as
    before), that's the easiest way.
     
    regards, Martin
     

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!
    Monday, June 18, 2012 11:53 AM
  • Are there generic variables for the all users start menu and all users all programs menu that will work for XP and Windows 7 32 and 64?
    • Edited by MyGposts Tuesday, June 19, 2012 3:26 PM
    Tuesday, June 19, 2012 3:26 PM
  •  
    > Are there generic variables for the all users start menu and all users
    > all programs menu that will work for XP and Windows 7 32 and 64?
     
    No - both are "Special Folders" that can be retrieved through operating
    system calls. And of course, you can implement a GPP Environment Item
    that is able to retrieve these special folders (press F3...) and put
    them in environment variables...
     

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!
    • Marked as answer by MyGposts Wednesday, June 20, 2012 6:47 PM
    Wednesday, June 20, 2012 1:40 PM