保存并显示.bat中的用户输入值不起作用 [英] save and display user input values in .bat not working

查看:77
本文介绍了保存并显示.bat中的用户输入值不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚为什么该值未存储在Windows 10的变量中. 我在互联网上搜索时没有任何原因无法解决该问题.

I am unable to figure out why the value is not stored in a variable in Windows 10. I search on the internet didn't get any reason why this not working.

@echo off
:start
REM check if there are more then one argumnets
if not "%2" == "" (
echo Too many parameters entered 
) ELSE (
REM check if argument one is empty
SETLOCAL ENABLEDELAYEDEXPANSION
if "%1"=="" (
echo "Enter your Name"
SET /P filename=
echo Your Name  is "%filename %" 
) 
if "%filename%"=="" (
echo "empty"
) else (
 echo "dat"
)
) 

运行此命令时:

Enter your Name
asd
Your Name  is

我做错什么了吗?

推荐答案

这也可能对您有所帮助:

This may also help you out:

@Echo Off
SetLocal EnableDelayedExpansion
If "%~1"=="" (
    Echo No parameter was passed
    GoTo EndIt
) Else (
    If Not "%~2" == "" (
        Echo Too many parameters entered 
        GoTo EndIt
    ) Else (
        Echo "Enter your Name"
        Set /P "filename="
        If "!filename!"=="" (
            Echo "empty"
        ) Else (
            Echo Your Name  is "!filename!"
            Echo "dat"
        )
    )
)
:EndIt
Pause
GoTo :EOF

这篇关于保存并显示.bat中的用户输入值不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆