Create script to execute program passing only part of the name

1

I created a small script ( .bat ) for the installation of several programs silently.

Over time the programs will update by requiring that I edit the code to enter the version number of the program.

Doubt: Is it possible to tell the CMD that regardless of the end of the program name it can find and install this program?

Example of how it is.

start cmd /C "Winrar 5.40 (x64)" /S
start cmd /C "Chrome 56" /silent /install
start cmd /C "Firefox 52.0 (x64)" -ms

Example of how you wanted it to be. (Locate independent of the end of the principal name.)

start cmd /C "Winrar *" /S
start cmd /C "Chrome *" /silent /install
start cmd /C "Firefox *" -ms

I studied SQL and when you need to say everything we use * .

I thought I could use * to do the same in CMD plus this does not apply because every language is a situation.

    
asked by anonymous 23.03.2017 / 17:56

1 answer

1

Save the content below as exec.bat :

@echo off
    setlocal
    set EXECUTAVEL=
    for %%i in (%1*.exe) do set EXECUTAVEL=%%i
    if /i not "%EXECUTAVEL%"=="" (
       echo Executando "%EXECUTAVEL%"...
       call "%EXECUTAVEL%"
    )
    endlocal

Run in the executable's current folder:

exec Chrome
    
28.03.2017 / 14:06