frapep
Goto Top

Batch-Datei bricht bei for Befehl ab: kann syntaktisch an dieser Stelle nicht verarbeitet werden

Hallo zusammen,
leider bin ich über die Suche nicht fündig geworden und erhoffe mir hier Hilfe.

Über ein von einem Dienstleister zur Verfügung gestellte Batch-Skript soll eine vom selben Dienstleister gelieferte Java-Software mittels mitgelieferte Java-Umgebung gestartet werden. Allerdings bricht das Batch mittendrin ab.

Mithilfe eines Echo-On- und Pause-Befehls konnte ich die Abbruchmeldung herausfinden:
image

Die Fehlermeldung lautet: "[PFAD-DATEINAME].jar kann syntaktisch an dieser Stelle nicht verarbeitet werden."

Es sind ziemlich viele *.jar-Dateien, die verarbeitet werden müssen und bei mehreren Durchläufen bricht das Batch an unterschiedlichen Stellen ab.

Der Aufrufbefehl im Batch lauet:

set BATCHCLIENTPATH=%~sdp0
set CLASSPATH=.
for %%i in (%BATCHCLIENTPATH%studio\plugins\*.jar) do ( call :exec %%i )

Laut Hersteller sei mit der Batch-Datei alles in Ordnung.

Weiß hier jemand Bescheid, woran der Abbruch liegen kann und warum es bei hunderten *jars klappt und bei dann bei jedes Mal anderen nicht?
Bei Rückfragen gebe ich gerne Auskunft (soweit ich darf face-smile).

Vielen Dank,
Florian

PS: ich bin kein Progammierer, daher entschuldigt bitte meine fachlich nicht perfekte Ausdrucksweise

Content-Key: 655064

Url: https://administrator.de/contentid/655064

Printed on: April 16, 2024 at 12:04 o'clock

Member: Meierjo
Meierjo Feb 22, 2021 at 17:17:00 (UTC)
Goto Top
Hallo

Sieht so aus, als hast du am Ende des Dateinamens noch einen Leerschlag drin.
Das hat Batch gar nicht gern

Ich würde probieren, den Dateinamen inklusive Pfad in Anführungszeichen zu packen, dann sollte das Problem nicht mehr bestehen
Etwa so (ungetestet):
for %%i in ("%BATCHCLIENTPATH%studio\plugins\*.jar") do ( call :exec %%i )  

Gruss
Member: frapep
frapep Feb 23, 2021 at 10:42:45 (UTC)
Goto Top
Hallo,

vielen Dank für den Tipp. Das hat aber leider noch nicht geklappt. Er bricht wieder an einer scheinbar zufälligen Stelle ab.

Hier einmal das komplette Skript inkl der Anführungszeichen im for-Befehl:

@echo on

REM the extended command for starting XYZ Studio
REM
REM start /min %BATCHCLIENTPATH%jre\bin\javaw.exe -Djava.net.useSystemProxies=true -Dhttp.proxyHost=HTTP_PROXY_HOST -Dhttp.proxyPort=HTTP_PROXY_PORT -Dhttps.proxyHost=HTTPS_PROXY_HOST -Dhttps.proxyPort=HTTPS_PROXY_PORT -Dhttp.nonProxyHosts=HTTP_NON_PROXY_HOSTS -cp %CLASSPATH% com.XYZ.studio.ws.launcher.InstallerLauncher
REM 
REM -Djava.net.useSystemProxies=true should be removed if the system proxies are not required
REM -Dhttp.proxyHost=HTTP_PROXY_HOST and -Dhttp.proxyPort=HTTP_PROXY_PORT indicate the proxy host and port, when HTTP proxy is required
REM -Dhttps.proxyHost=HTTPS_PROXY_HOST and -Dhttps.proxyPort=HTTPS_PROXY_PORT indicate the proxy host and port, when HTTPS proxy is required
REM -Dhttp.nonProxyHosts=HTTP_NON_PROXY_HOSTS indicates the hosts that should be accessed without going through the proxy
REM

set BATCHCLIENTPATH=%~sdp0
set CLASSPATH=.
for %%i in ("%BATCHCLIENTPATH%studio\plugins\*.jar") do ( call :exec %%i )  

REM the command for starting XYZ Studio
start /min %BATCHCLIENTPATH%jre\bin\java.exe -Djava.net.useSystemProxies=true -cp %CLASSPATH% com.XYZ.studio.ws.launcher.InstallerLauncher

goto :eof

:exec
set CLASSPATH=%CLASSPATH%;%*

:eof
pause

Vielleicht hilft das jemandem weiter um das Problem zu lösen.
Member: TK1987
TK1987 Feb 23, 2021 at 11:21:22 (UTC)
Goto Top
Moin,

versuche es mal damit:
@echo on
Setlocal EnableDelayedExpansion

REM the extended command for starting XYZ Studio
REM
REM start /min %BATCHCLIENTPATH%jre\bin\javaw.exe -Djava.net.useSystemProxies=true -Dhttp.proxyHost=HTTP_PROXY_HOST -Dhttp.proxyPort=HTTP_PROXY_PORT -Dhttps.proxyHost=HTTPS_PROXY_HOST -Dhttps.proxyPort=HTTPS_PROXY_PORT -Dhttp.nonProxyHosts=HTTP_NON_PROXY_HOSTS -cp %CLASSPATH% com.XYZ.studio.ws.launcher.InstallerLauncher
REM 
REM -Djava.net.useSystemProxies=true should be removed if the system proxies are not required
REM -Dhttp.proxyHost=HTTP_PROXY_HOST and -Dhttp.proxyPort=HTTP_PROXY_PORT indicate the proxy host and port, when HTTP proxy is required
REM -Dhttps.proxyHost=HTTPS_PROXY_HOST and -Dhttps.proxyPort=HTTPS_PROXY_PORT indicate the proxy host and port, when HTTPS proxy is required
REM -Dhttp.nonProxyHosts=HTTP_NON_PROXY_HOSTS indicates the hosts that should be accessed without going through the proxy
REM

set BATCHCLIENTPATH=%~sdp0
set CLASSPATH=.
for %%i in ("%BATCHCLIENTPATH%studio\plugins\*.jar") do set "CLASSPATH=!CLASSPATH!;%%i"  

REM the command for starting XYZ Studio
start /min %BATCHCLIENTPATH%jre\bin\java.exe -Djava.net.useSystemProxies=true -cp %CLASSPATH% com.XYZ.studio.ws.launcher.InstallerLauncher

Sollte den selben Zweck erfüllen und weniger fehleranfällig sein.

Gruß Thomas