How to open a new shell in cmd,then run script in a new shell?

前端 未结 4 1464
旧巷少年郎
旧巷少年郎 2021-01-13 20:25

My computer\'s OS is win7

I want to use a .bat file to open a new shell, then run script in a new shell

this shell is OSGeo4W Shell

it is located in

4条回答
  •  滥情空心
    2021-01-13 21:03

    i had similar problem, and i managed to resolved like this: I had a script file called script.bat with various python and ogr functions. In separate bat file i typed:

    call "C:\Program Files\QGIS 2.14\OSGeo4w.bat" start cmd.exe /k  script  
    pause
    

    This bat file calls inital script.bat in OSGeo4W Shell.

    *note1: Both bat files must be in same directory. **note2: In your case script.bat will have content:

    ogr2ogr -f CSV my_csv Grid.dbf
    ogr2ogr -f CSV csv Grid.dbf
    addcenter.exe
    ogr2ogr -f "ESRI Shapefile" my_dir ./csv/Grid.csv
    copy Grid.shp my_dir
    copy Grid.shx my_dir
    rd my_csv /s /q
    rd csv /s /q
    ogr2ogr -clipsrc t.shp test.shp ./my_dir/Grid.shp
    rd my_dir /s /q
    ogr2ogr -f CSV wellcsv welllocation.dbf
    ogr2ogr -f CSV csv test.dbf
    computingArea.exe
    ogr2ogr -f "ESRI Shapefile" my_dir ./csv/test.csv
    rd csv /s /q
    rd wellcsv /s /q
    move test.shp my_dir
    move test.shx my_dir
    del test.dbf /q
    

    and separate bat file will be:

    call "C:\Program Files\QGIS Dufour\OSGeo4w.bat" start cmd.exe /k  script 
    

    and both bat files must be in directory with data (C:\Users\tony\Downloads\11\computingArea). I hope this will work, it worked for me!

提交回复
热议问题