5

I try to launch an .exe file in a very simple batch script.

The problem I'm faced in is that I don't know the name of the target folder where the program is located cause it's suffixed by the version number.

I've already tried various ways using wildcards but that don't seems to works.

I mean, if I cd into a path it works but not when I want to start a program.

Working example:

cd C:\my-program-folder-*.*.*

Failing example:

C:\my-program-folder-*.*.*\prog.exe
  • What is the actual full path? – root Feb 23 '16 at 21:38
  • The actual full-path is C:\test-1.2.3\GPU-Z.exe – TwystO Feb 23 '16 at 21:43
  • 1
    Since it's a batch file already, why not just CD into the folder using the wildcards first, and then just launch prog.exe, without specifying the path? BTW: cd c:\my-program-folder-* should be enough, no need for the extra .*.*, as there are no 'extensions' on folder names (just names with dots in them) – Ƭᴇcʜιᴇ007 Feb 23 '16 at 21:52
  • 1
    @Ƭᴇcʜιᴇ007 Big thanks! It's so evident, I don't know why I don't try this way before. – TwystO Feb 23 '16 at 22:02
  • 2
    No problem, @DavidPostill <strike>stole</strike> has the answer and posted it, so go give him the checkmark (he needs them or his body will start to turn into fragrant goo). ;) – Ƭᴇcʜιᴇ007 Feb 23 '16 at 22:05
3

How do I execute a program using wildcards in the path

Working example:

cd C:\my-program-folder-*.*.*

Failing example:

C:\my-program-folder-*.*.*\prog.exe

You can use:

cd C:\test-* && GPU-Z.exe

Note:

  • && - if the previous command (cd C:\test-*) succeeds then run the next command (GPU-Z.exe)

Further Reading

  • Note that this will fail if there are multiple matching directories and the first match isn't the one you need. – akom Jul 17 '17 at 17:08
1

This another approch :

For example i don't know the location of the folder that contains this file vbc.exe : The Visual Basic compiler.

So, i can do like this :

@echo off
Title To find the last version of .NET Framework Compilateur vbc.exe and execute it in command line
color 0b
for /F %%i in ('dir /B /S ^"%WinDir%\Microsoft.NET\*vbc.exe^"') do set vbc=%%i
if /i "%vbc%"=="" cls & color 1c & echo You don't have any version of .NET Framework Compilateur vbc.exe & pause & exit
echo The last version of .NET Framework Compilateur vbc.exe is located at this path :
echo. 
echo %vbc%
echo.
echo Press any key to run it !
pause>nul
cls
cmd /k %vbc%
pause

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.