Findstr无法与SET/P一起使用? [英] Findstr does not work with SET /P?

查看:122
本文介绍了Findstr无法与SET/P一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理文件,其一部分如下所示:

    rem @echo off
    cd C:\Program Files\CA\AllFusion Gen\GEN\test8.ief\c\
    FINDSTR /C:"'V1600 OPER'"  /C:"'V1714 OPER'" /C:"'V1801 OPER'" /C:"'V1901 OPER'" "MPOAD10C"

上面的批处理文件使用上面的代码成功运行.但是,当我修改脚本以使用户可以输入两个变量时,如下所示(%path%= test8.ief,%file_name%= MPOAD10C),它会引发以下错误:

'FINDSTR'不被识别为内部或外部命令,可运行程序或批处理文件.

    rem @echo off
    SET /P path=Enter name of IEF folder:
    echo. && echo.
    SET /P file_name=Enter name of file:
    echo. && echo.
    cd C:\Program Files\CA\AllFusion Gen\GEN\%path%\c
    FINDSTR /C:"'V1600 OPER'" /C:"'V1714 OPER'" /C:"'R18 V1801 OPER'" /C:"'V1901 OPER'" "%file_name%"

我还在环境变量的PATH变量中输入了值"C:\ WINDOWS \ system32".

我对批处理脚本非常陌生.请帮忙.预先感谢.

关于, 莫希特·古普塔(Mohit Gupta).

解决方案

请勿将path用作您自己的变量之一,Windows会使用该特定环境变量来查找可执行文件,例如findstr您刚刚发现了.

将其更改为类似mypath之类的内容,您的问题应会消失.

I have a batch file with a portion shown below:

    rem @echo off
    cd C:\Program Files\CA\AllFusion Gen\GEN\test8.ief\c\
    FINDSTR /C:"'V1600 OPER'"  /C:"'V1714 OPER'" /C:"'V1801 OPER'" /C:"'V1901 OPER'" "MPOAD10C"

The above batch file runs successfully with the above code. However, when I modified the script so that the user can enter two variables, as shown below (%path%=test8.ief,%file_name%=MPOAD10C), it throws the following error:

'FINDSTR' is not recognized as an internal or external command,operable program or batch file.

    rem @echo off
    SET /P path=Enter name of IEF folder:
    echo. && echo.
    SET /P file_name=Enter name of file:
    echo. && echo.
    cd C:\Program Files\CA\AllFusion Gen\GEN\%path%\c
    FINDSTR /C:"'V1600 OPER'" /C:"'V1714 OPER'" /C:"'R18 V1801 OPER'" /C:"'V1901 OPER'" "%file_name%"

I have also entered the value "C:\WINDOWS\system32" in the PATH variable in the Environment Variables.

I am very new to batch scripting. Please help. Thanks in advance.

Regards, Mohit Gupta.

解决方案

Don't use path as one of your own variables, that particular environment variable is used by Windows to locate executable files, such as findstr as you've just discovered.

Change it to something like mypath and your problem should disappear.

这篇关于Findstr无法与SET/P一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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