Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Find and then run executable via batch file?  (Read 4423 times)

0 Members and 1 Guest are viewing this topic.

nintendo1889

    Topic Starter


    Newbie

    • Experience: Experienced
    • OS: Windows 7
    Find and then run executable via batch file?
    « on: May 20, 2014, 10:58:56 AM »
    I am trying to build computers, and I am writing a batch file to remove the junk.

    I have found one application that doesn't seem to have an uninstaller string in the registry, but I've found that this will uninstall it without prompting:

    "C:\SWSETUP\APP\PreReq1\HP\HPSupportAssist\7.2.23.56\src\UninstallHPSA.exe" /S

    Is there a way to find this program and run it if the folder changes? I don't mind including a few cygwin utilities, even bash, with my script, if they'll help.

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Find and then run executable via batch file?
    « Reply #1 on: May 20, 2014, 02:17:58 PM »
    You can use IF EXIST in a batch file to test to see if the file exists, and if it does to then run this script. It can be added to startup folder of system that tests upon everytime the system is turned on or logged into with users who have this added to startup, or you can add it as an after hours scheduled task to perform this uninstall unattended if it exists.

    http://stackoverflow.com/questions/4340350/how-to-check-if-a-file-exists-from-inside-a-batch-file

    So yours would be something like this, where you would place the file to be detected as a positive for confirmation of installation into the "insert file name here" which would have to be brought to the directory containing the file to check for, for it to know where it is :

    Code: [Select]
    if exist {insert file name here} (
        rem file exists
        START "C:\SWSETUP\APP\PreReq1\HP\HPSupportAssist\7.2.23.56\src\UninstallHPSA.exe" /S


    ) else (
        rem file doesn't exist - do nothing
    )