138701
Goto Top

":" Kann an dieser Stelle syntaktisch nicht verarbeitet werden

Hallo zusammen,

Hier erstmal mein Programm:
@echo off
title Login System
color 0C
for /f "delims=" %%x in (Game\Profile\temp.ini) do set "profile=%%x"  
:start
set key=
set print=
set newkey=
cls
echo =====Login System=====
echo.
echo 1: Edit your secret notes.
echo 2: Generate new key.
echo 3: Delete your profile.
echo 4: Go back to main sytem.
echo.
echo What do you want to do?
choice /c 1234
if %errorlevel%==1 (
  start Game\Profile\%profile%\diary.rtf
  goto start
)
if %errorlevel%==2 goto overwrite
if %errorlevel%==3 goto delete
if %errorlevel%==4 (
  start _Main.bat
  exit
)
if %errorlevel%==255 goto start
goto start
::######################################################################
:overwrite
for /f "delims=" %%x in (Game\Profile\%profile%\key.txt) do set "key=%%x"  
set /a newkey=1+(10000-1+1)*%random%/32768
cls
::In der nächsten Zeile kommt die Fehlermeldung.
call :find "%profile%;%key%" && (  
  findstr /ilvc:"%profile%;%key%" "Game\Profile\profiles.db" >"%TEMP%\profiles.db" & move "%TEMP%\profiles.db" "Game\Profile\profiles.db"  
  echo Your new key is %newkey%.
  echo %newkey%>Game\Profile\%profile%\key.txt
  set /p print=Should the new key be printed? (yes/no): 
  if %print%==yes (
    NOTEPAD /P Game\Profile\%profile%\key.txt
    cls
    echo Successfully printed!
  )
  setlocal ENABLEDELAYEDEXPANSION
  >>"Game\Profile\profiles.db" echo.!profile!;!newkey!  
  echo.
  echo Profile successfully edited!
  endlocal
  timeout /t 5 >nul
  goto start
) || (
  echo Profile does not exist!
  echo.
  timeout /t 5 >nul
  goto start
)
goto start
::######################################################################
:delete
for /f "delims=" %%x in (Game\Profile\%profile%\key.txt) do set "key=%%x"  
cls
call :0 "%profile%;%key%" && (  
  findstr /ilvc:"%profile%;%key%" "Game\Profile\profiles.db" >"%TEMP%\profiles.db" & move "%TEMP%\profiles.db" "Game\Profile\profiles.db" >nul  
  attrib -h -s Game\Profile\%profile%\diary.rtf
  del Game\Profile\%profile% /s /q
  echo Profile has been deleted.
  timeout /t 5 >nul
  goto start
) || (
  echo Profile does not exist!
  echo.
  timeout /t 5 >nul
  goto start
)
:find
::Der Fehler liegt nicht an dieser Zeile!
findstr /ibelc:"%~1" "Game\Profile\profiles.db" >nul 2>&1 && exit /b 0 || exit /b 1  

Ich bekomme jedes Mal folgende Fehlermeldung:

":" kann an dieser Stelle syntaktisch nicht verarbeitet werden.  

Kann sich jemand vorstellen warum?
Ich komme nicht mehr weiter :/

Content-Key: 416389

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

Ausgedruckt am: 29.03.2024 um 01:03 Uhr

Mitglied: Penny.Cilin
Penny.Cilin 10.02.2019 um 12:34:09 Uhr
Goto Top
Hallo,

wo genau tritt die Fehlermeldung auf. Um dies heraus zu finden, nutze statt
@echo off
einfach
@Echo O
n oder setze den Eintrag einfach auf
REMARK
.

Gruss Penny
Mitglied: rubberman
rubberman 10.02.2019 um 13:20:28 Uhr
Goto Top
Wie wahrscheinlich ist es denn dass "%profile%;%key%"zu einem String expandiert, in dem zusätzliche Anführungszeichen zu finden sind?

::Der Fehler liegt nicht an dieser Zeile!
Mag schon sein, aber die Optionen b und e in Kombination sollten sicher eher Option x werden. Weiß gerade gar nicht wie findstr auf sowas reagiert.

Steffen
Mitglied: Pjordorf
Pjordorf 10.02.2019 um 13:25:17 Uhr
Goto Top
Hallo,

Zitat von @138701:
Hier erstmal mein Programm:
OK. Batch. Mach mal ein
@echo on
oder ein
REM @echo on
dann wirst du sehen wo du dein(e) Fehler eingearbeitet hast. Deine verwendung von :: als Kommentar kann, muss aber nicht, dein Problem schon darstellen. Nur REM tut ganz genau was es soll und hat in der verwendung keinerlei nebenwirkungen.
https://www.robvanderwoude.com/comments.php
https://stackoverrun.com/de/q/4522895

::In der nächsten Zeile kommt die Fehlermeldung.
Und wie du siehst sind der Verwendung von Umlauten je nach OS nicht wirklich gelungen

":" kann an dieser Stelle syntaktisch nicht verarbeitet werden.  

Kann sich jemand vorstellen warum?
Steht doch da. Deine verwendung von :: als Kommentar sind dein Problem

Gruß,
Peter
Mitglied: 138701
138701 10.02.2019 aktualisiert um 16:26:32 Uhr
Goto Top
@penny
Ich habe im Programm geschrieben wo der Fehler liegt.

Siehe Zeile 36...
Mitglied: 138701
138701 10.02.2019 um 16:25:48 Uhr
Goto Top
@peter
Das hatte ich alles schon gemacht.
Der Fehler liegt ganz sicher in Zeile 37!
Ich habe nach jeder Zeile Pause eingefügt und es hat sich ergeben, dass das Programm ab dieser Zeile nicht mehr funktioniert.
Mitglied: Pjordorf
Pjordorf 10.02.2019 um 16:47:20 Uhr
Goto Top
Hallo,

Zitat von @138701:
Das hatte ich alles schon gemacht.
Das bedeutet du hast alle :: gegen ein REM ausgetauscgt, die Codierung deiner Batch geändert oder dein OS angepasst? Du hast auch Verstanden das deine :: nebenwirkungen haben (können)?

Der Fehler liegt ganz sicher in Zeile 37!
Immer noch?

Ich habe nach jeder Zeile Pause eingefügt und es hat sich ergeben, dass das Programm ab dieser Zeile nicht mehr funktioniert.
Dann hast du nach wie vor ein Fehler.face-smile

Gruß,
Peter
Mitglied: Penny.Cilin
Penny.Cilin 10.02.2019 um 18:20:04 Uhr
Goto Top
Hallo,

wer Sprungziele nach internen Kommandos benennt, gehört erschossen.
Benenne das Sprungziel in Zeile 37
call :find
und Zeile 78
:find
um.

Gruss Penny
Mitglied: 138701
138701 10.02.2019 aktualisiert um 20:49:28 Uhr
Goto Top
@peter
Das hat mir nicht geholfen.

Ich habe alle :: entfernt und der Fehler war nach wie vor da.
Mitglied: 138701
138701 10.02.2019 um 21:07:37 Uhr
Goto Top
ICH HABE DEN FEHLER GEFUNDEN!

Ich hatte in einer If-Schleife eine zweite If-Schleife.
Diese hat durch die zusätzlichen Klammern die erste abgehackt.
Hier das verbesserte Programm:

@echo off
title Login System
color 0C
for /f "delims=" %%x in (Game\Profile\temp.ini) do set "profile=%%x"  
for /f "delims=" %%x in (Game\Profile\%profile%\key.txt) do set "key=%%x"  
:start
set print=
set newkey=
cls
echo =====Login System=====
echo.
echo 1: Edit your secret notes.
echo 2: Generate new key.
echo 3: Delete your profile.
echo 4: Go back to main sytem.
echo.
echo What do you want to do?
choice /c 1234
if %errorlevel%==1 (
  start Game\Profile\%profile%\diary.rtf
  goto start
)
if %errorlevel%==2 goto overwrite
if %errorlevel%==3 goto delete
if %errorlevel%==4 (
  start _Main.bat
  exit
)
if %errorlevel%==255 goto start
goto start
:overwrite
set /a newkey=1+(10000-1+1)*%random%/32768
cls
call :find "%profile%;%key%" && (  
  findstr /ilvc:"%profile%;%key%" "Game\Profile\profiles.db" >"%TEMP%\profiles.db" & move "%TEMP%\profiles.db" "Game\Profile\profiles.db"  
  goto o1
) || (
  echo Profile does not exist!
  echo.
  timeout /t 5 >nul
  goto start
)
goto start
:delete
cls
call :find "%profile%;%key%" && (  
  findstr /ilvc:"%profile%;%key%" "Game\Profile\profiles.db" >"%TEMP%\profiles.db" & move "%TEMP%\profiles.db" "Game\Profile\profiles.db" >nul  
  attrib -h -s Game\Profile\%profile%\diary.rtf
  echo nul>Game\Profile\temp.ini
  del Game\Profile\%profile% /s /q
  cls
  echo Profile has been deleted.
  timeout /t 5 >nul
  exit
) || (
  cls
  echo Profile does not exist!
  echo.
  timeout /t 5 >nul
  goto start
)
:find
findstr /ibelc:"%~1" "Game\Profile\profiles.db" >nul 2>&1 && exit /b 0 || exit /b 1  
:o1
echo Your new key is %newkey%.
echo %newkey%>Game\Profile\%profile%\key.txt
echo.
echo Should the new key be printed?
set /p print=yes/no: 
if %print%==yes (
  NOTEPAD /P Game\Profile\%profile%\key.txt
  cls
  echo Key successfully printed!
)
setlocal ENABLEDELAYEDEXPANSION
>>"Game\Profile\profiles.db" echo.!profile!;!newkey!  
cls
echo Profile successfully edited!
endlocal
timeout /t 5 >nul
goto start

Es läuft jetzt einwandfrei!