![]() |
Ersatz für Batch Befehl CHOICE ?
Hallo Leute
Ich krame gerade in meinen alten Batch-Dateien. Zumindest bei WinXP kennt der CMD Interpreter den Befehl CHOICE nicht mehr. Gibt es eine Alternative? :gruebel: Hier ein Beispiel:
Code:
@echo off
CLS :loop1 echo Bitte Netzwerkkartentreiber wählen: echo echo 1 = Dell Latitude C840 echo 2 = PC .. choice /c:12 if errorlevel 2 goto net2 if errorlevel 1 goto net1 goto loop1 :net1 echo \net\netbind.com goto exit :net2 echo \net\net... goto exit :exit EXIT |
Re: Ersatz für Batch Befehl CHOICE ?
Hi.
Schau dir mal den Schalter /P des SET-Befehls an. Damit sollte sich was reißen lassen. Grüße vom marabu |
Re: Ersatz für Batch Befehl CHOICE ?
Code:
Ein Beispiel.
@ECHO OFF
CLS :Start ECHO. ECHO [1] Start Nummer 1 ECHO [2] Start Nummer 2 ECHO [3] Beenden ECHO. SET choice= SET /P choice=Bitte Auswählen (1 bis 3): IF NOT ´%choice%´==´´ SET choice=%choice:~0,1% if ´%choice%´==´1´ goto Run1 if ´%choice%´==´2´ goto Run2 if ´%choice%´==´3´ goto Exit ECHO "%choice%" ist keine gültige Eingabe. Bitte noch einmal: ECHO. GOTO Start :Run1 ECHO Start Nummer 1 REM ... goto end :Run2 Start Nummer 2 REM ... goto end :Exit ECHO Beendet durch User GOTO End :End |
Re: Ersatz für Batch Befehl CHOICE ?
Zitat:
|
Re: Ersatz für Batch Befehl CHOICE ?
Hi Sharky,
wenn ich Unmengen an choice-verseuchten Script-Code hätte, dann würde ich CHOICE aus dem W2K3 resource kit holen. Wenn nicht, dann nehme ich doch lieber einen internen Befehl der command shell mit vergleichbarer Funktionalität. Grüße vom marabu |
Re: Ersatz für Batch Befehl CHOICE ?
Also mein Batch sieht jetzt so aus:
Code:
Dank an marabu und turboPASCAL :thumb:
@ECHO OFF
CLS :Start ECHO. ECHO [1] Dell Latitude C840 ECHO [2] PC001 ECHO [3] Abbruch ECHO. SET choice= SET /P choice=Bitte Auswählen (1 bis 3): IF NOT ´%choice%´==´´ SET choice=%choice:~0,1% if ´%choice%´==´1´ goto Run1 if ´%choice%´==´2´ goto Run2 if ´%choice%´==´3´ goto Exit ECHO "%choice%" ist keine gueltige Eingabe. Bitte noch einmal: ECHO. GOTO Start :Run1 echo \net\netbind.com REM ... goto end :Run2 echo \net\net... REM ... goto end :Exit ECHO Beendet durch User GOTO End :End Einziger Wermutstropfen ist die Reaktion wenn nur die Return-Taste betätigt wird:
Code:
Das würde ich gern noch abfangen.
"┤==┤1┤" ist syntaktisch an dieser Stelle nicht verarbeitbar.
|
Re: Ersatz für Batch Befehl CHOICE ?
Welches Betriebssystem und gff. welcher Zeichensatz (DOS) ?
Du kannst das ja auch mit einer kleinen Konsolenanwendung machen, Sichwort ![]() :gruebel: |
Re: Ersatz für Batch Befehl CHOICE ?
Zitat:
Zitat:
Aber ich denke ich kann schon gut mit dem aktuellen batch leben... Nochmals vielen Dank für die Tips :hi: |
Re: Ersatz für Batch Befehl CHOICE ?
Zitat:
|
Re: Ersatz für Batch Befehl CHOICE ?
Ahoi,
Zitat:
bye, Andy |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:05 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz