Here is your user prompt demo batch file with additional command lines to safely process the user input. The batch file contains remarks to explain the code.
@echo off
setlocal EnableExtensions DisableDelayedExpansion
title User prompt demo
cls
:GetName
rem Undefine the environment variable Name.
set "Name="
rem Prompt the user for the name.
set /P "Name=What is your name? "
rem Has the user just pressed RETURN or ENTER without entering a string?
if not defined Name goto GetName
rem Remove all double quotes from user input string.
set "Name=%Name:"=%"
rem Has the user entered just double quotes?
if not defined Name goto GetName
rem Output an empty line.
echo(
rem Enable delayed expansion and output the input string which could
rem contain characters like ampersands, angle brackets or pipes which
rem would modify the command line with ECHO before execution on not
rem using delayed environment variable expansion. The exclamation mark
rem at end must be escaped twice with caret character to be interpreted
rem as literal character to print by command ECHO in this case. Then
rem restore the previous execution environment as defined at top.
setlocal EnableDelayedExpansion
echo Hello !Name!^^!
endlocal
echo(
echo inserted text here
echo inserted text here
echo inserted text here
echo inserted text here
echo inserted text here
echo(
rem A classic yes/no prompt is done best with using command CHOICE which
rem is by default available since Windows Vista and Windows Server 2003.
%SystemRoot%\System32\choice.exe /C YN /N /M "What is the password, yes or no? (Y,N):"
if errorlevel 2 exit /B
rem The user pressed key Y and so the batch file processing continues.
echo(
echo Secret file: %UserProfile%\Desktop\name\files
endlocal
To understand the commands used and how they work, open a command prompt window, execute there the following commands, and read the displayed help pages for each command, entirely and carefully.
choice /?
cls /?
echo /?
endlocal /?
exit /?
goto /?
if /?
rem /?
set /?
setlocal /?
title /?
See also:
You could be also interested in How to create a directory in the user's desktop directory? It offers a batch file with a few lines to determine directly from Windows registry which directory is the user's desktop directory because of %UserProfile%\Desktop
is just the default and every user has the freedom to use a different directory as desktop directory with a few clicks.