melmacker
Goto Top

Wie schreibe ich diese Befehle von einer Batch-Datei in eine andere Batch-Datei?

Hallo erstmal,
Ich benötige Hilfe bei dem einfügen von Befehlen die ich von einer Batch-Datei in eine andere Batch-Datei schreibe und ja ich habe es schon probiert mit echo (Befehl) > (Datei) das geht nämlich bei meinen Befehlen nicht zumindest nicht bei allen weil ich möchte das die erste Batch-Datei (1.bat) in die zweite Batch-Datei (2.bat) schriebt das 2.bat eine Zahl in eine Beispiel.txt schreiben soll. Entschuldigung schon mal im voraus wegen den Satzzeichen bzw. Rechtschreibung
Das sind die Befehle die die 1.bat in die 2.bat schreiben soll:

@echo off
:begin
timeout /t 3
set /p "x="<"Y:\Produkt2.txt"
set /a x=%x%+1
echo %x% >Produkt2.txt
goto begin

Würde mich über eine schnelle Antwort freuen :D
Mit Vielen Grüßen
Melmacker


Hier ist der komplette Code:


@echo off
@title Cookie Clicker

set /a Cookies=0
set /a Produkt1=1
set /a Anzahl1=0
set /a Produkt2=0
set /a Anzahl2=0
set /a Preis1=1
set /a Preis2=20
set /a x=0

:start

::Testet ob die BatbBox existiert::
if not exist batbox.exe goto create
if not exist Produkt2.txt goto createProdukt2txt
if not exist Produkt2.bat goto createProdukt2bat
cls
echo.
echo      _.:::::._
echo    .:::::::::::.
echo   /:::::::::::::\
echo  !:::::::::::::::!                            ###########
echo  !:::::::::::::::!                            # S H O P #
echo  !:::::::::::::::!                            ###########
echo   \:::::::::::::/
echo    ':::::::::::'  
echo      `'"""""'`  
echo.
echo.
echo Du hast %Cookies% Cookies.
 FOR /F "tokens=1,2,3 delims=:" %%A in ('BatBox /m') DO (  
  SET %3=%%C
  SET %2=%%B
  SET %1=%%A
::Ihr müsst immer in dieser klammer programmieren ausserdem ist %%A die Breite %%B die Tiefe::
if %%A==5 if %%B==1 goto Cookie
if %%A==6 if %%B==1 goto Cookie
if %%A==7 if %%B==1 goto Cookie
if %%A==8 if %%B==1 goto Cookie
if %%A==9 if %%B==1 goto Cookie
if %%A==10 if %%B==1 goto Cookie
if %%A==11 if %%B==1 goto Cookie
if %%A==12 if %%B==1 goto Cookie
if %%A==13 if %%B==1 goto Cookie
if %%A==3 if %%B==2 goto Cookie
if %%A==4 if %%B==2 goto Cookie
if %%A==5 if %%B==2 goto Cookie
if %%A==6 if %%B==2 goto Cookie
if %%A==7 if %%B==2 goto Cookie
if %%A==8 if %%B==2 goto Cookie
if %%A==9 if %%B==2 goto Cookie
if %%A==10 if %%B==2 goto Cookie
if %%A==11 if %%B==2 goto Cookie
if %%A==12 if %%B==2 goto Cookie
if %%A==13 if %%B==2 goto Cookie
if %%A==14 if %%B==2 goto Cookie
if %%A==15 if %%B==2 goto Cookie
if %%A==2 if %%B==3 goto Cookie
if %%A==3 if %%B==3 goto Cookie
if %%A==4 if %%B==3 goto Cookie
if %%A==5 if %%B==3 goto Cookie
if %%A==6 if %%B==3 goto Cookie
if %%A==7 if %%B==3 goto Cookie
if %%A==8 if %%B==3 goto Cookie
if %%A==9 if %%B==3 goto Cookie
if %%A==10 if %%B==3 goto Cookie
if %%A==11 if %%B==3 goto Cookie
if %%A==12 if %%B==3 goto Cookie
if %%A==13 if %%B==3 goto Cookie
if %%A==14 if %%B==3 goto Cookie
if %%A==15 if %%B==3 goto Cookie
if %%A==16 if %%B==3 goto Cookie
if %%A==1 if %%B==4 goto Cookie
if %%A==2 if %%B==4 goto Cookie
if %%A==3 if %%B==4 goto Cookie
if %%A==4 if %%B==4 goto Cookie
if %%A==5 if %%B==4 goto Cookie
if %%A==6 if %%B==4 goto Cookie
if %%A==7 if %%B==4 goto Cookie
if %%A==8 if %%B==4 goto Cookie
if %%A==9 if %%B==4 goto Cookie
if %%A==10 if %%B==4 goto Cookie
if %%A==11 if %%B==4 goto Cookie
if %%A==12 if %%B==4 goto Cookie
if %%A==13 if %%B==4 goto Cookie
if %%A==14 if %%B==4 goto Cookie
if %%A==15 if %%B==4 goto Cookie
if %%A==16 if %%B==4 goto Cookie
if %%A==17 if %%B==4 goto Cookie
if %%A==46 if %%B==4 goto Shop
if %%A==47 if %%B==4 goto Shop
if %%A==48 if %%B==4 goto Shop
if %%A==49 if %%B==4 goto Shop
if %%A==50 if %%B==4 goto Shop
if %%A==51 if %%B==4 goto Shop
if %%A==52 if %%B==4 goto Shop
if %%A==53 if %%B==4 goto Shop
if %%A==54 if %%B==4 goto Shop
if %%A==55 if %%B==4 goto Shop
if %%A==56 if %%B==4 goto Shop
if %%A==1 if %%B==5 goto Cookie
if %%A==2 if %%B==5 goto Cookie
if %%A==3 if %%B==5 goto Cookie
if %%A==4 if %%B==5 goto Cookie
if %%A==5 if %%B==5 goto Cookie
if %%A==6 if %%B==5 goto Cookie
if %%A==7 if %%B==5 goto Cookie
if %%A==8 if %%B==5 goto Cookie
if %%A==9 if %%B==5 goto Cookie
if %%A==10 if %%B==5 goto Cookie
if %%A==11 if %%B==5 goto Cookie
if %%A==12 if %%B==5 goto Cookie
if %%A==13 if %%B==5 goto Cookie
if %%A==14 if %%B==5 goto Cookie
if %%A==15 if %%B==5 goto Cookie
if %%A==16 if %%B==5 goto Cookie
if %%A==17 if %%B==5 goto Cookie
if %%A==46 if %%B==5 goto Shop
if %%A==47 if %%B==5 goto Shop
if %%A==48 if %%B==5 goto Shop
if %%A==49 if %%B==5 goto Shop
if %%A==50 if %%B==5 goto Shop
if %%A==51 if %%B==5 goto Shop
if %%A==52 if %%B==5 goto Shop
if %%A==53 if %%B==5 goto Shop
if %%A==54 if %%B==5 goto Shop
if %%A==55 if %%B==5 goto Shop
if %%A==56 if %%B==5 goto Shop
if %%A==1 if %%B==6 goto Cookie
if %%A==2 if %%B==6 goto Cookie
if %%A==3 if %%B==6 goto Cookie
if %%A==4 if %%B==6 goto Cookie
if %%A==5 if %%B==6 goto Cookie
if %%A==6 if %%B==6 goto Cookie
if %%A==7 if %%B==6 goto Cookie
if %%A==8 if %%B==6 goto Cookie
if %%A==9 if %%B==6 goto Cookie
if %%A==10 if %%B==6 goto Cookie
if %%A==11 if %%B==6 goto Cookie
if %%A==12 if %%B==6 goto Cookie
if %%A==13 if %%B==6 goto Cookie
if %%A==14 if %%B==6 goto Cookie
if %%A==15 if %%B==6 goto Cookie
if %%A==16 if %%B==6 goto Cookie
if %%A==17 if %%B==6 goto Cookie
if %%A==46 if %%B==6 goto Shop
if %%A==47 if %%B==6 goto Shop
if %%A==48 if %%B==6 goto Shop
if %%A==49 if %%B==6 goto Shop
if %%A==50 if %%B==6 goto Shop
if %%A==51 if %%B==6 goto Shop
if %%A==52 if %%B==6 goto Shop
if %%A==53 if %%B==6 goto Shop
if %%A==54 if %%B==6 goto Shop
if %%A==55 if %%B==6 goto Shop
if %%A==56 if %%B==6 goto Shop
if %%A==2 if %%B==7 goto Cookie
if %%A==3 if %%B==7 goto Cookie
if %%A==4 if %%B==7 goto Cookie
if %%A==5 if %%B==7 goto Cookie
if %%A==6 if %%B==7 goto Cookie
if %%A==7 if %%B==7 goto Cookie
if %%A==8 if %%B==7 goto Cookie
if %%A==9 if %%B==7 goto Cookie
if %%A==10 if %%B==7 goto Cookie
if %%A==11 if %%B==7 goto Cookie
if %%A==12 if %%B==7 goto Cookie
if %%A==13 if %%B==7 goto Cookie
if %%A==14 if %%B==7 goto Cookie
if %%A==15 if %%B==7 goto Cookie
if %%A==16 if %%B==7 goto Cookie
if %%A==3 if %%B==8 goto Cookie
if %%A==4 if %%B==8 goto Cookie
if %%A==5 if %%B==8 goto Cookie
if %%A==6 if %%B==8 goto Cookie
if %%A==7 if %%B==8 goto Cookie
if %%A==8 if %%B==8 goto Cookie
if %%A==9 if %%B==8 goto Cookie
if %%A==10 if %%B==8 goto Cookie
if %%A==11 if %%B==8 goto Cookie
if %%A==12 if %%B==8 goto Cookie
if %%A==13 if %%B==8 goto Cookie
if %%A==14 if %%B==8 goto Cookie
if %%A==15 if %%B==8 goto Cookie
if %%A==5 if %%B==9 goto Cookie
if %%A==6 if %%B==9 goto Cookie
if %%A==7 if %%B==9 goto Cookie
if %%A==8 if %%B==9 goto Cookie
if %%A==9 if %%B==9 goto Cookie
if %%A==10 if %%B==9 goto Cookie
if %%A==11 if %%B==9 goto Cookie
if %%A==12 if %%B==9 goto Cookie
if %%A==13 if %%B==9 goto Cookie
 )
goto start


:Cookie
cls
set /a Cookies=%Cookies%+%Produkt1%
set /p "x="<"Y:\Produkt2.txt"  
if %x%==0 goto start
if %x% GEQ 1 goto plus
goto start


:plus
set /a Cookies=%Cookies%+%x%
echo 0 >Produkt2.txt
goto start


:Shop
cls
echo.
echo Kaufen:           Name:                  Preis:
echo.
echo       Mehrere Cookies pro Click        %Preis1%
echo.
echo       Automatischer Cookie Generator   %Preis2%
echo.
echo   --    Um den Shop zu verlassen         -
echo.
echo.
echo   Du bist im Besitz von %Anzahl1% Mehreren Cookies pro Click.
echo.
echo   Du bist im Besitz von %Anzahl2% Automatischen Cookies Generatoren.
echo.
 FOR /F "tokens=1,2,3 delims=:" %%A in ('BatBox /m') DO (  
  SET %3=%%C
  SET %2=%%B
  SET %1=%%A
::Ihr müsst immer in dieser klammer programmieren ausserdem ist %%A die Breite %%B die Tiefe::
if %%A==2 if %%B==3 goto Produkt1
if %%A==3 if %%B==3 goto Produkt1
if %%A==2 if %%B==5 goto Produkt2
if %%A==3 if %%B==5 goto Produkt2
if %%A==2 if %%B==7 goto start
if %%A==3 if %%B==7 goto start
)
goto Shop


:Produkt1
cls
if not %Cookies% GEQ %Preis1% goto nicht
set /a Produkt1=%Produkt1%*2
set /a Preis1=%Preis1%*4
set /a Anzahl1=%Anzahl1%+1
goto Shop


:Produkt2
cls
if not %Cookies% GEQ %Preis2% goto nicht
set /a Produkt2=%Produkt2%+1
set /a Preis2=%Preis2%*4
set /a Anzahl2=%Anzahl2%+1
start Produkt2.bat
goto Shop


:nicht
cls
echo.
echo Du hast nicht Genug Cookies um das zu kaufen.
timeout /t 2 > NULL & del NULL
goto Shop


:createProdukt2txt
echo. > Produkt2.txt
echo 0 >Produkt2.txt
goto start


:createProdukt2bat
echo Bitte kopieren sie erst die unten stehenden Befehle in die Produkt2.bat.
echo.
echo Machen sie erst weiter wenn sie die Befehle in Produkt2.bat kopiert haben.
echo. > Produkt2.bat

echo @echo off>>Produkt2.bat
echo :begin>>Produkt2.bat
echo timeout /t 3>>Produkt2.bat
echo set /p "x="<"Y:\Produkt2.txt">>Produkt2.bat  
echo set /a x=%x%+1>>Produkt2.bat
echo echo %x% >Produkt2.txt>>Produkt2.bat
echo goto begin>>Produkt2.bat

goto start

::Dies erstellt die BatBox::
:create
 for %%b in (
 4D5343460000000073030000000000002C000000000000000301010001000000
 00000000470000000100010000060000000000000000FE4259B5200062617462
 6F782E657865003FD9412724030006434BB5545F485361143F5737F0CF726B3A
 102ABB528B1EC24813421026D3529AB59C184460D7ED6EF7CE79EFB8F74A562F
 0B1D543EF5143DC60483C27AF0C14248B18710A4979ECA40426A0329A1B21ECA
 AF73EE9D4E21B287FAB6DF77CFF99DF37DDFEF3B3B779D1752C001800D5CC018
 808F1C1C3ED879A41015FB9F56C064E942ED141758A8ED96649D4F6A6A4C1306
 F8B0A028AAC1F789BC36A8F0B2C2B79E0DF1036A44ACDB557670638F601B4080
 E3A0C3FBFDDC06B7044EAE9CE34EA2283041C3B505A48E9E450079B99B69C05B
 FC4B1457BC75DD6666DECD8F981BE02EF71797FDC7A32E9A100C7C1EB1E505D9
 2CDD5BC7252AC57F1E92ABCA0771EB21D968029C98E76125D25F9967D1ED838C
 8372D6F24E093AD9175832FFADCAD43C7F8C459F9442D39D1E8C3947C6913F15
 7BB79A7BCD18CBA6D10BB24687B9E33226E4E6904E5DE37A9DE90A3C9C7926F1
 98F48C73E401F2CC731FBD66BAB2335D6E8689B0336A13E6798C76B601772CB6
 F7E2565EEAD64C1589A931C93092B34B2ECE4E1C6BB466EBE82C1DDD4E8A3ED3
 5ED25137B163B861AE9ED8B7D452F182D42F945F4D111213920E14F28B908D57
 B3C61233710903560539A9DA3CD0E257901F6EA600D664019744879B295EE44C
 3F43EF9BFD303A3FD172A61FE13CDABC17FD9BEBB39F5CD7DFD3BDEEF155565D
 6E63B4D8CC0E9EEF910E15745C5D47755EAB32AB245726A20A890C55275B4616
 952417A44035BA71FC8498670A970F3F77CCCD7E2862E3F524D44EBFBB6D741F
 3D46F7A4DF3847E885988B835574AF0EDE4893F9056F1874970F26101F111711
 B6DD3EA8411C472C20A611FD31211C8D0CA89737DAEC4665A1E532F8CA8DA13F
 ED2E7013682FBA7FDFA29DA11E7F57775D6B2000A7DBBACEB4051AEA4D077EE0
 02076E54833881E846488864FEB09DE2D8AAA2113222ED82124988E48744C3AF
 2ABA9A103BF17F6A3BD32D0E192D86A1C97D8386B82DE21FD474550BAABA6CC8
 AA42ABBA4421920F7628C941A385F213A298DCB6AE55D69309E18A79D40C6A9A
 47BC422C2356106B799D7F8AE16D345931A264F5C644232C9916990382AC085A
 4C475F1C920D93EFEF932C4B3734434D00FC02                          
 ) Do >>t.dat (Echo.For b=1 To len^("%%b"^) Step 2  
 ECHO WScript.StdOut.Write Chr^(Clng^("&H"^&Mid^("%%b",b,2^)^)^) : Next)  
 Cscript /b /e:vbs t.dat>batbox.ex_
 Del /f /q /a t.dat >nul 2>&1
 Expand -r batbox.ex_ >nul 2>&1
 Del /f /q /a batbox.ex_ >nul 2>&1
goto start

Content-Key: 387790

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

Ausgedruckt am: 29.03.2024 um 06:03 Uhr

Mitglied: 137289
Lösung 137289 27.09.2018 aktualisiert um 11:42:50 Uhr
Goto Top
@echo off
>"D:\Pfad\2.bat" (  
	echo @echo off
	echo :begin
	echo timeout /t 3
	echo set /p x=^<"Y:\Produkt2.txt"  
	echo set /a x=%%x%%+1
	echo ^>"Produkt2.txt" echo(%%x%%   
	echo goto begin
)
Gruß speedlink
Mitglied: Melmacker
Melmacker 27.09.2018 um 11:43:39 Uhr
Goto Top
Da kommt bei mir aber folgendes raus:

@echo off
:begin
timeout /t 3
set /p x=<"Y:\Produkt2.txt"  
set /a x=%x%+1
>"Produkt2.txt" echo %x%   
goto begin

Gruß Melmacker
Mitglied: 137289
Lösung 137289 27.09.2018 aktualisiert um 11:48:33 Uhr
Goto Top
Na und ist doch korrekt.

Umleitungen in Dateien sollte man nach Best Practice immer vorne an schreiben, denn wenn Variablen z.B. eine "2" enthalten kommt nichts in der Datei an weil das StdErr bedeutet! Außerdem wenn %x% leer wäre würde ein "Echo On BlaBla ... " in die Datei geschrieben!! Deswegen ist das die fehlerunanfälligste Form
Mitglied: Melmacker
Melmacker 27.09.2018 um 11:48:00 Uhr
Goto Top
Hab einen eigenen Fehler gemacht sorry ;D

Vielen Dank für die schnelle Hilfe :D

Melmacker