简体   繁体   中英

Execute command in Windows batch file

I have a file located on a share folder. I have to execute that file from the local PC. The name of the file changes every day, hence I should find the name first and then execute that .exe file.

Here is my Batch :

@echo off

set FILE =

FOR  /F  %%a IN ('dir /s/b') DO (  
  set FILE=%%a
)

start %FILE%

The last line does not execute the file. Why is that?

Does it have spaces in the path?

Try this:

START "" "%FILE%"

The "" signifies an empty window title. When you quote the filename you have to specify a title, otherwise START will treat your quoted file path as the title.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM