/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Batch Script

05/25/2018 577 views

Hi

Please give me batch script that search for .exe file
if file is present then it should execute that .exe file
if no it should quit

Regards,
Sarika

2 Comments   [ + ] Show comments

Comments

  • ...show us your attempt first and I'm sure someone on here would gladly assist.
  • ::========================================================================================

    set log_file_path="%TEMP%\%~n0.log"
    ::Delete the current log file
    if exist %log_file_path% del /Q %log_file_path%


    ::DEFAULT: silent Installation


    ::========================================================================================
    ::Helper Functions
    ::========================================================================================
    goto END_FUNCTION_SECTION_


    ::---------------------------------
    ::Performs Installation
    ::---------------------------------
    :funcInstall
    setlocal
    set ERROR_SUCCESS=0

    :if not exist"%windir%\system32\CompattelRunner.exe"
    :GOTO:EOF

    if exist "%windir%\system32\CompattelRunner.exe"
    start schtasks.exe /CHANGE /TN "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /DISABLE

    if %errorlevel%==%ERROR_SUCCESS% goto SUCCESS_

    :ERROR_
    ::------------------------------------------
    ::print out Machine Name, product code, product name
    ::to the network log file for the product that failed to uninstall
    set Installation_result=Failed, Result=%errorlevel%
    goto DONE_

    :SUCCESS_
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Brand_MSCompatabilityAppraiser_DisableTask
    set Installation_result=Succeeded
    goto DONE_

    :DONE_

    endlocal
    GOTO:EOF

    :END_FUNCTION_SECTION_


    ::::== Defender Update
    call :funcInstall

All Answers

2
I won't go sifting through your code but you can try something like this:

@ECHO OFF
SET FileToFind="%WINDIR%\notepad.exe"
IF EXIST %FileToFind% (
REM File found.  Run file
    START /B /WAIT "" "%FileToFind%"
) ELSE (
REM Exit with non zero exit code
    EXIT /B 1
)
Answered 05/25/2018 by: captain_planet
Black 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