Powershell 带有空格的批处理脚本用户输入

Powershell 带有空格的批处理脚本用户输入,powershell,batch-file,scripting,Powershell,Batch File,Scripting,我试图有一个脚本,需要用户输入一个文件夹名称,当一个没有空格的名称被写入时,一切都正常,但每次写入一个带有空格的文件夹名称时,这不是我的代码。有人能帮我解决那个问题吗 @echo off if not exist "%USERPROFILE%\Desktop\Backup" mkdir C:\Users\%USERPROFILE%\Desktop\Backup set backupdir=%USERPROFILE%\Desktop\Backup set backupcmd=xcopy /s

我试图有一个脚本,需要用户输入一个文件夹名称,当一个没有空格的名称被写入时,一切都正常,但每次写入一个带有空格的文件夹名称时,这不是我的代码。有人能帮我解决那个问题吗

@echo off


if not exist "%USERPROFILE%\Desktop\Backup" mkdir C:\Users\%USERPROFILE%\Desktop\Backup
set backupdir=%USERPROFILE%\Desktop\Backup
set backupcmd=xcopy /s /c /d /e /h /i /r /y


:loop

echo Your current directory is
echo %cd%

echo.

echo These are the folders in your derectory.
dir /a:d /b

echo.

echo Type the name of a folder to move into that directory or back to move to the previous directory. 
echo Once you get to the directory you want type finish in order to backup that directory.

:user_input
set /p  userInput= Enter Directory Name or type finish to back the files : 
echo.

if %userInput% == back (
    cd ..
) else if not exist %userInput% (
    if not %userInput% == finish (
        echo This directory doesnt exist please try again.
        goto:user_input
    )
) else if "%userInput%" (
    cd %cd%\%userInput%
)

if %userInput% == finish (

    goto:backup_start
) else (
    goto:loop
)



:backup_start
%backupcmd% "%cd%" "%backupdir%"

echo Backup Complete
@pause

else如果“%userInput%”(
?请再想一想。为什么这篇文章会被标记为
powershell
?elsi如果“%userInput%”就是问题所在。谢谢大家花时间帮助我。