2017-10-12 19 views
-2

今、バッチプログラムのユーザーが.txtファイルを編集できるようにする方法を見つけようとしています。私はすでにファイルを作成しているバッチファイルを持っていますが、今はそれを作成して、.txtファイルにユーザーが質問に対して回答したものがあるようにする必要があります。ここで私は今持っているものです。バッチから編集可能なtxtファイルを作成するにはどうすればよいですか?

@echo off 
echo Welcome to the Space Mapping Discord Report Maker 
pause 
echo Made by N3ther, version 0.1 ALPHA 
pause 
@echo off 
break>"%userdomain%\%username%\Desktop\report.txt" 
echo Question 1: What is your username on Discord?` 

(それは私が司会の午前レポートメーカーのためです。)

答えて

0

以下のようなものは、何が必要であるように見えます:理解のために

@echo off 
setlocal EnableExtensions EnableDelayedExpansion 
set "ReportFile=%USERPROFILE%\Desktop\report.txt" 
del "%ReportFile%" 2>nul 

echo Welcome to the Space Mapping Discord Report Maker 
echo/ 
echo Made by N3ther, version 0.1 ALPHA 
echo/ 

call :PromptUser 1 "What is your username on Discord?" 
call :PromptUser 2 "What is ...?" 

rem Restore saved environment and exit batch processing. 
endlocal 
goto :EOF 

rem This small subroutine prompts the user for an input until something is 
rem entered at all and then appends the entered input to the report file. 

:PromptUser 
set "Input=" 
:PromptAgain 
set /P "Input=Question %~1: %~2 " 
rem Has the user entered anything at all? 
if not defined Input goto PromptAgain 
echo !Input!>>"%ReportFile%" 
goto :EOF 

コマンドプロンプトウィンドウを開き、次のコマンドを実行し、コマンドごとに表示されているすべてのヘルプページを非常に注意深く読んでください。

  • call /?
  • del /?
  • echo /?
  • endlocal /?
  • goto /?
  • if /?
  • rem /?
  • set /?
  • setlocal /?

も読むUsing Command Redirection OperatorsWindows Environment Variablesに関するWikipediaの記事についてMicrosoftの記事。

関連する問題