Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

batch dont work! "if file exist, run, else, exit"

Featured Replies

Did you tried this:

if not exist "%CDROM%\1.EXE" goto next
if exist "%CDROM%\1.EXE" (start "" /wait "%CDROM%\1.EXE")
:next
"D:\2.EXE"


Fine, he's all yours...

Edited by MrJinje

could be that "if" parameter is bad written?

IF EXIST "%CDROM%\1.EXE" (START "" /WAIT "%CDROM%\1.EXE")
"D:\2.EXE"

Your if is bad written because you don't have good parenthesis. You need make every command go inside one set of parenthesis, but that doesn't matter, because you ignore my posts, so I am wasting my time telling you. Good luck figuring it out.

IF EXIST "D:\1.EXE" (START "" /WAIT "D:\1.EXE"
"C:\2.EXE")

Well I disagree here, the code you've quoted was mine and was given because it was believed to be correct for the task which was intended.
if exist "%CDROM%\1.exe" (Start /wait "%CDROM%\1.exe") run "C:\2.exe" ELSE (run "C:\2.exe")
exit

It appears from that example that C:\2.exe is intended to be run regardless of whether or not %CDROM%\1.exe exists, (it is found on both sides of the ELSE statement). For that reason the parentheses are closed correctly.

At the final script is resolved as follows:

@ Echo off
for %%i in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) do if exist %%i\1.exe start /wait %%i\1.exe
"%~dp02.exe"

The error was SET CDROM=%%i:

Edited by maestrodellaves

At the final script is resolved as follows: <snip />
Well without seeing the script I would be hesitant in believing that anything has been solved.

If I was however going to use the 'check every letter of the alphabet' method then I'd probably use a system to break the loop when found. (the trouble with the method you've suggested is that if the file is found at D:, the script would still check for it a E: F: G:.. etc.)

@ECHO OFF
SETLOCAL
(SET HOST_DRV=)
FOR %%# IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO (
CALL :SUB %%#:||GOTO :NEXT)
:NEXT
REM The commands you provided in your last message.

IF DEFINED HOST_DRV START "" /WAIT "%HOST_DRV%\1.EXE"
IF EXIST "C:\2.EXE" START "" /WAIT "C:\2.EXE"

REM The rest of your commands go here.




GOTO :EOF
:SUB
IF EXIST %1\1.EXE (SET "HOST_DRV=%1"&&EXIT/B 1)
EXIT/B 0

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.