diff --git a/file_assoc.cmd b/file_assoc.cmd new file mode 100644 index 0000000..3e45feb --- /dev/null +++ b/file_assoc.cmd @@ -0,0 +1,28 @@ +@echo off +rem This script associates the .cbscript file extension with +rem the corresponding commmand to compile it, located in run.cmd + +:admincheck + rem Checks if the file is running with administrator privileges + if "%PROCESSOR_ARCHITECTURE%" equ "amd64" ( + >nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" + ) else ( + >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" + ) + + if "%errorlevel%" equ "0" goto main + +:noadmin + echo Not running as administrator. + echo Requesting administrative privileges... + powershell -Command "Start-Process -Verb RunAs -FilePath '%0'" + exit /b + +:main + assoc .cbscript=CBScript + ftype CBScript=%~dp0run.cmd "%%1" %%* + + echo. + echo Successfully associated CBScript (.cbscript) files + + pause \ No newline at end of file diff --git a/run.cmd b/run.cmd index 58f245a..527069b 100644 --- a/run.cmd +++ b/run.cmd @@ -1,12 +1,28 @@ -@rem To make double clicking cbscript files work, modify: -@rem \HKEY_CLASSES_ROOT\cbscript_auto_file\shell\open\command -@rem Set the string value to the file location of this file followed by "%1" -@rem For example: "D:\Dropbox\Projects\Python\CBScript 1.16\run.cmd" "%1" -@rem -@rem To generate blocks.json, via command prompt at the minecraft server: -@rem java -DbundlerMainClass=net.minecraft.data.Main -jar {jar_path} --server --reports -@ECHO CBScript 1.20 -@title %~nx1 -@cd "%~dp0" -py -3 compile.py %1 -@pause \ No newline at end of file +@echo off +rem To make double clicking cbscript files work, either: +rem 1. Run file_assoc.cmd +rem 2. Modify +rem \HKEY_CLASSES_ROOT\cbscript_auto_file\shell\open\command +rem Set the string value to the file location of this file followed by "%1" +rem For example: "D:\Dropbox\Projects\Python\CBScript 1.16\run.cmd" "%1" +rem +rem To generate blocks.json, via command prompt at the minecraft server: +rem java -DbundlerMainClass=net.minecraft.data.Main -jar {jar_path} --server --reports + +echo CBScript 1.20 +title %~nx1 + +if "%1" == "" ( + echo You must specify a file path. + exit /b +) + +if not exist "%1" ( + echo The specified file does not exist. + exit /b +) + +cd "%~dp0" +py compile.py %1 + +pause