Detecting if a file is open in a batch file

后端 未结 3 766
灰色年华
灰色年华 2020-12-30 14:02

Say I have a batch file for carrying out a long build and at the end it creates an EXE. If I forget to close the app down before I start the build, the link phase fails whe

3条回答
  •  情书的邮戳
    2020-12-30 14:52

    Found a better way:

    :start
    timeout /T 5
    
    if exist %1 (
    2>nul (
      >> %1  (call )
    ) && (goto ende) || (goto start) ) else ( exit )
    
    
    :ende
    YourCode
    

    This will check every after 5 seconds for "is the file in use" if it its it will start again. if not it turns to ende where you can do your next options

提交回复
热议问题