简体   繁体   English

批处理文件以“无法识别...命令”运行,如何解决此问题?

[英]Batch file runs with “not recognized…command”, how to fix this?

I have a batch file which when executed sets PATHs, prompts user for input and loads a script via Python. 我有一个批处理文件,该文件在执行时会设置PATH,提示用户输入并通过Python加载脚本。 The python script creates a grid with the size of each cell determined by the user input variable ( cellsize ). python脚本创建一个网格,每个网格的大小由用户输入变量( cellsize )确定。 The following is from my .bat file: 以下是来自我的.bat文件:

@echo off
rem Root OSGEO4W home dir to the following directory
call "C:\OSGeo4W64\bin\o4w_env.bat"

rem List available o4w programs
rem but only if osgeo4w called without parameters
@echo on

set PYTHONPATH=C:\OSGeo4W64\apps\qgis\python
set PATH=C:\OSGeo4W64\apps\qgis\bin;%PATH%

@echo off
echo.
set /p cellsize="Enter cellsize: "
cellsize=1
cmd /k python "Script.py" %cellsize%
@echo on

The .bat works the way it's supposed to, I obtain the correct results, but I receive the following error: .bat以预期的方式工作,我获得了正确的结果,但是收到以下错误:

'cellsize' is not recognized as an internal or external command, operable program or batch file 无法将“ cellsize”识别为内部或外部命令,可操作程序或批处理文件

What simple mistake(s) did I make? 我犯了什么简单的错误? I am a beginner but still learning. 我是初学者,但仍在学习。

@echo off
echo.
set /p cellsize="Enter cellsize: "
set cellsize=1
cmd /k python "Script.py" %cellsize%
@echo on

you need set 你需要set

The line must read: 该行必须显示为:

set cellsize=1 设置单元格大小= 1

but surely this line seems more useful before the set /p line as an initialization, since otherwise it cancels the effect of that line. 但肯定此行似乎是集/ P线作为初始化之前更加有用,因为否则取消该行的效果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复“py”未被识别为内部或外部命令、可运行程序或批处理文件 - How to fix 'py' is not recognized as an internal or external command, operable program or batch file 如何修复错误:“make”不是内部或外部命令、可运行程序或批处理文件 - How to fix error : 'make' is not recognized as an internal or external command, operable program or batch file 如何解决错误“'py.exe'不被识别为内部或外部命令,可操作程序或批处理文件”的错误? - How to fix error “'py.exe' is not recognized as an internal or external command, operable program or batch file”? 如何修复“auto-py-to-exe”不被识别为内部或外部命令、可运行程序或批处理文件 - how to fix 'auto-py-to-exe' is not recognized as an internal or external command, operable program or batch file 如何修复“'audiogrep' 未被识别为内部或外部命令”? - How to fix “ 'audiogrep' is not recognized as an internal or external command”? 'command' 不是内部或外部命令,也不是可运行的程序 或批处理文件 - 'command' is not recognized as an internal or external command, operable program or batch file 未被识别为内部或外部命令、可运行的程序或批处理文件 - Not recognized as an internal or external command, operable program or batch file pip 不是内部或外部命令,也不是可运行的程序或批处理文件 - pip is not recognized as an internal or external command, operable program or batch file 'net' 在 python 中不是内部或外部命令,也不是可运行的程序或批处理文件 - 'net' is not recognized as an internal or external command, operable program or batch file in python 'From/import' 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'From/import' is not recognized as an internal or external command, operable program or batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM