Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions file_assoc.cmd
Original file line number Diff line number Diff line change
@@ -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
40 changes: 28 additions & 12 deletions run.cmd
Original file line number Diff line number Diff line change
@@ -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
@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