批处理文件以 "not recognized...command" 运行,如何解决这个问题?
Batch file runs with "not recognized...command", how to fix this?
我有一个批处理文件,执行时会设置 PATH,提示用户输入并通过 Python 加载脚本。 python 脚本创建一个网格,其中每个单元格的大小由用户输入变量 (cellsize
) 确定。以下内容来自我的 .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
.bat 按预期方式工作,我获得了正确的结果,但我收到以下错误:
'cellsize' is not recognized as an internal or external command, operable program or batch file
我犯了什么简单的错误?我是初学者,但仍在学习中。
@echo off
echo.
set /p cellsize="Enter cellsize: "
set cellsize=1
cmd /k python "Script.py" %cellsize%
@echo on
你需要set
该行必须为:
set cellsize=1
但肯定这一行似乎更有用在 set /p 行作为初始化之前,否则它会取消该行的效果。
我有一个批处理文件,执行时会设置 PATH,提示用户输入并通过 Python 加载脚本。 python 脚本创建一个网格,其中每个单元格的大小由用户输入变量 (cellsize
) 确定。以下内容来自我的 .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
.bat 按预期方式工作,我获得了正确的结果,但我收到以下错误:
'cellsize' is not recognized as an internal or external command, operable program or batch file
我犯了什么简单的错误?我是初学者,但仍在学习中。
@echo off
echo.
set /p cellsize="Enter cellsize: "
set cellsize=1
cmd /k python "Script.py" %cellsize%
@echo on
你需要set
该行必须为:
set cellsize=1
但肯定这一行似乎更有用在 set /p 行作为初始化之前,否则它会取消该行的效果。