程序在执行时关闭(批处理)

Program closes when executed (Bathc)

所以这应该检查此文件是否存在于 %HOMEPATH% 中,但它只能在 10:05 和 13:15

之间执行
@echo off & cls
color 8f
set HORA = %time:~0,2%%time:~3,2%
if %HORA% GEQ 1005 (
    if %HORA% LEQ 1315 (
        cd %HOMEPATH%
        if EXIST Desktop (
            echo Desktop hi es >> registre.log
            ) ELSE ( echo Desktop no hi es >> registre.log
            )
        if EXIST Music (
            echo Music hi es > registre.log
            ) ELSE ( echo Music no hi es > registre.log
            )
        if EXIST Documents (
            echo Mis Documentos hi es > registre.log
            ) ELSE ( Mis Documentos no hi es > registre.log
            )
        if EXIST Downloads (
            echo Descarregues hi es > registre.log
            ) ELSE ( Descarregues no hi es > registre.log
            )
        type registre.log
        pause > nul
        del registre.log
    )
)
echo Ara no es pot executar
pause
exit

当我打开文件时它立即关闭

          v.......................... space included in variable value 
set HORA = %time:~0,2%%time:~3,2%
        ^...........................  space included in variable name

因此,要引用您的变量,您需要 %HORA %。最好改成

set "HORA=%time:~0,2%%time:~3,2%"

不包含在值中的空格和引号也会阻止在行尾包含额外的空格。