Close Menu
    Facebook X (Twitter) Instagram
    Tuesday, May 13
    X (Twitter) LinkedIn
    All about Endpoint Management
    • Home
    All about Endpoint Management
    Home»CM2012»Batch script Search for string in registry key ,if found perform uninstallation

    Batch script Search for string in registry key ,if found perform uninstallation

    Eswar KonetiBy Eswar KonetiNovember 26, 6:25 pm2 Mins Read CM2012 1,678 Views
    Share
    Facebook Twitter LinkedIn Reddit

    Last week,I was working on Intergraph application upgrade to latest version.Client has different versions of Intergraph and the removal of older versions is not straight forward like other applications using msiexec /x{ProductID} /qn.

    The command line is different for all these versions and I cannot put these command lines in one script and run on remote computers using Configmgr. Doing by so,will give error on the higher version of clients while running uninstallation for older applications.For ex: client is having Version 2011 R2 and when the script runs ,it will have 2011 R1 uninstallation command line ,this will give error saying ,you cannot perform this on newer version installed computer.

    This process leads me to write simple batch script to check if the specific application name (what I supposed to remove) found in registry then perform the uninstall actions for each version ,if not found simply do nothing.

    This batch script is to search for specific application display name ,if found,do some custom actions like uninstallation or what needed.

    @echo off
    REM Title : Search application name from registry

    REM Scanning registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node) for any old applications and remove
    REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /F  "Application Name1" /S
    REM Application name1 can be anything ,like display name or product ID etc.
    IF %ERRORLEVEL% EQU 0 (
    REM write your custom query here
    )

    REM Scanning registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node) for any old applications and remove
    REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /F  "Application Name2" /S
    REM Application name2 can be anything ,like display name or product ID etc.
    IF %ERRORLEVEL% EQU 0 (
    REM write your custom query here
    )

     

    batch Batch Script reg query SCCM SCCM 2012 script search string in registry uninstallation
    Share. Twitter LinkedIn Email Facebook Reddit

    Related Posts

    Optimize Your Intune Workflow with a Powerful Browser Extension

    March 22, 10:39 am

    Migrate Microsoft 365 Updates from SCCM/MECM to Intune for Co-Managed Devices

    February 11, 9:50 pm

    Investigating Co-Management Issues with Windows Endpoints in SCCM/Intune

    October 26, 10:45 pm

    3 Comments

    1. madhu ranganath on June 26, 2015 7:09 PM

      Thank you

      Reply
    2. Madhu S on June 26, 2015 6:40 PM

      It would be more useful for us if you provide the exact script which you have used in your scenario.
      And one doubt if we need to uninstall the previous versions lets assume 10, then we need to write 10 times of the above same pseudo Coden for un install 10 previous version of same application.

      Reply
      • Eswar Koneti on June 29, 2015 5:21 PM

        yes,if you go with this type of batch file and not use msiexec /x uninstallation method. Normally for msi removals,you can just go with msiexec /x method for all .IF the product code found ,it will remove else it will ignore but in my case,its completly different uninstall method .Below is command what i used to remove the intergraph .
        REM Scanning registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node) for any old applications and remove

        REG Query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall /F "Intergraph SmartPlant Markup" /S
        IF %ERRORLEVEL% EQU 0 (
        REM Uninstall HF#4 for 2011 R1
        "\\sccmserver\application name\setup.exe" -s /f1"\\sccmservername\application name\Uninstall_SPM2011.iss" /f2"C:\windows\temp\uninstall_SPM.log"
        )
        so the above cmd line will try to remove using the recorded file (.iss) .

        Reply

    Leave a ReplyCancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Sign Up

    Get email notifications for new posts.

    Author

    I’m Eswar Koneti ,a tech enthusiast, security advocate, and your guide to Microsoft Intune and Modern Device Management. My goal? To turn complex tech into actionable insights for a streamlined management experience. Let’s navigate this journey together!

    Support

    Awards

    Archives

    © Copyright 2009-2024 Eswar Koneti, All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.