if not defined OSGEO4W_DESKTOP for /F "tokens=* USEBACKQ" %%F IN (`getspecialfolder Desktop`) do set OSGEO4W_DESKTOP=%%F
for /F "tokens=* USEBACKQ" %%F IN (`getspecialfolder Documents`) do set DOCUMENTS=%%F

copy bin\qgis-bin.exe bin\qgis-bin-grass.exe
copy bin\qgis-bin.vars bin\qgis-bin-grass.vars
call "%OSGEO4W_ROOT%\bin\qgis-grass.bat" --postinstall
echo on

if not %OSGEO4W_MENU_LINKS%==0 if not exist "%OSGEO4W_STARTMENU%" mkdir "%OSGEO4W_STARTMENU%"
if not %OSGEO4W_DESKTOP_LINKS%==0 if not exist "%OSGEO4W_DESKTOP%" mkdir "%OSGEO4W_DESKTOP%"

if not %OSGEO4W_MENU_LINKS%==0 xxmklink "%OSGEO4W_STARTMENU%\QGIS Desktop 3.18.0 with GRASS 7.8.5.lnk" "%OSGEO4W_ROOT%\bin\qgis-bin-grass.exe" "" "%DOCUMENTS%"
if not %OSGEO4W_DESKTOP_LINKS%==0 xxmklink "%OSGEO4W_DESKTOP%\QGIS Desktop 3.18.0 with GRASS 7.8.5.lnk" "%OSGEO4W_ROOT%\bin\qgis-bin-grass.exe" "" "%DOCUMENTS%"

del /s /q "%OSGEO4W_ROOT%\apps\qgis\grass\*.pyc"
exit /b 0
