1

バッチファイルを実行するたびに、すべてが実行されcheckfiles、に入るようですが、ifステートメントは動作しません。何も返されません。コードの最後の部分までスキップします。

:file_check
if exist "%psychedelia%\nhc.exe" (goto file_exists) else (timeout /t 1 /nobreak > output)
goto file_check

:file_exists
copy /Y "%~dp0version.txt" "%psychedelia%"

:checkfiles
echo in checkfiles
if exist "%psychedelia%\wa.exe" if exist "%psychedelia%\readme.txt" if exist "%psychedelia%\HD.BLB" if exist "%psychedelia%\smackw32.dll" if exist "%psychedelia%\setup95.exe" if exist "%psychedelia%\WAVistaWin7.exe" (
    echo MSGBOX "Thank you for installing the Neverhood. You may now go to your desktop and click on the Orpheus shortcut to play!" > %temp%\TEMPxmessage.vbs
    call %temp%\TEMPxmessage.vbs
    del %temp%\TEMPxmessage.vbs /f /q
    rename "%psychedelia%\nhc.exe" wa.exe
    timeout /t 1 /nobreak > output
    taskkill.exe /F /IM setup95.exe /T
) else ( 
    echo nonexistent
    pause
    timeout /t 1 /nobreak > output
    goto checkfiles
)

すべての助けは大歓迎です。

4

2 に答える 2

4

その行の最後だけif existに括弧が付いているので、elseその最後の行にのみ適用されます。最初のもののいずれかがfalseと評価された場合、それはすべてをスキップします。

于 2013-03-23T03:50:06.500 に答える
1

試す:

...
echo in checkfiles
for %%f in (wa.exe 
            readme.txt 
            HD.BLB 
            smackw32.dll 
            setup95.exe 
            WAVistaWin7.exe
           ) do if not exist "%psychedelia%\%%f" (
    echo %%f nonexistent
    pause
    timeout /t 1 /nobreak > output
    goto checkfiles
   )

:: all required files found

echo MSGBOX "Thank you for installing the Neverhood. You may now go to your desktop and click on the Orpheus shortcut to play!" > %temp%\TEMPxmessage.vbs
call %temp%\TEMPxmessage.vbs
del %temp%\TEMPxmessage.vbs /f /q
rename "%psychedelia%\nhc.exe" wa.exe
timeout /t 1 /nobreak > output
taskkill.exe /F /IM setup95.exe /T

メンテしやすいかも。

実際、あなたも書くことができます

set requiredfiles=wa.exe readme.txt HD.BLB smackw32.dll setup95.exe WAVistaWin7.exe
for %%f in (%requiredfiles%) do if not exist "%psychedelia%\%%f" (
...

これはさらに簡単です。

BUT PLEASE ACCEPT Nate Hekman's ANSWER - これはただの話です*

于 2013-03-23T05:34:37.550 に答える