以下のような繰り返しのコマンドラインをいくつか書きましたが、コマンドを単純化するために他の人からの入力があるのではないでしょうか。できるだけシンプルに。
@echo off
:stro
cls
echo.
echo Enter you term:
echo ++++++++++++++++++++++
echo 1) Command Prompt (CMD)
echo 2) Power Shell
echo 3) Exit
echo.
set /p kod=
if %kod% == 1 goto cmde
if %kod% == 2 goto pwsl
if %kod% == 3 goto exitx
:exitx
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "tuntu.vbs"
echo speech.speak "thank you for use me. i hope you have a nice day. bye bye" >> "tuntu.vbs"
attrib +h "tuntu.vbs"
start tuntu.vbs
pause
attrib -h "tuntu.vbs"
del tuntu.vbs
exit
:cmde
start cmd
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "tuntu.vbs"
echo speech.speak "you choice is number %kod% and you open command prompt CMD" >> "tuntu.vbs"
attrib +h "tuntu.vbs"
start tuntu.vbs
pause
attrib -h "tuntu.vbs"
del tuntu.vbs
goto stro
:pwsl
start powershell
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "tuntu.vbs"
echo speech.speak "you choice is number %kod% and you open Power shell" >> "tuntu.vbs"
attrib +h "tuntu.vbs"
start tuntu.vbs
pause
attrib -h "tuntu.vbs"
del tuntu.vbs
goto stro
次に、単純で、繰り返して退屈な文を含まないコマンドラインが必要です。お手伝いありがとう
vbs
スクリプトを1回だけ生成します(テキストをハードコーディングする代わりにパラメーターを使用します)。
次に、コードは次のように短縮されます。
@echo off
(echo set speech = Wscript.CreateObject("SAPI.spVoice"^)
echo speech.speak WScript.Arguments(0^))>"speak.vbs"
attrib +h speak.vbs
set "say=cscript /nologo speak.vbs"
:stro
cls
echo.
echo Enter you term:
echo ++++++++++++++++++++++
echo 1) Command Prompt (CMD)
echo 2) Power Shell
echo 3) Exit
echo.
choice /c 123
set kod=%errorlevel%
goto :label%kod%
:label3
%say% "thank you for using me. i hope you have a nice day. bye bye"
exit /b
:label1
start cmd
%say% "your choice is number %kod% and you open command prompt CMD"
goto stro
:label2
start powershell
%say% "your choice is number %kod% and you open Power shell"
goto stro
また、ユーザー入力を処理set /p
しchoice
、choice
無効な入力を防ぐため、をに置き換えました。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加