Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check Unity License and License
REM License Unity
SET unitySerial[0]=X4-XXXX-XXXX-XXXX-XXXX-XXXX
SET unitySerial[1]=X4-XXXX-XXXX-XXXX-XXXX-XXXX
SET unityUsername=redacted@example.com
SET unityPassword=redacted
REM See https://stackoverflow.com/questions/5777400/how-to-use-random-in-batch-script/5777608#5777608
REM This will return either 0 or 1, which we'll use below to set our variable to either unitySerial[0] or unitySerial[1]
set /a unitySerialNum=%random% %%2
set unitySerialToUse=!unitySerial[%unitySerialNum%]!
REM Check If the Unity_lic.ulf file exists
IF EXIST "C:\ProgramData\Unity\Unity_lic.ulf" (
findstr /MC:"StopDate Value=\"2020-12-24T00:00:00\"" C:\ProgramData\Unity\Unity_lic.ulf
if !errorlevel! == 0 (
REM Running pro version, do nothing!
) else (
REM Running outdated license, or personal edition, re-license it
del /s /q C:\ProgramData\Unity\Unity_lic.ulf >NUL 2>&1
PING 127.0.0.1 -n 5 >NUL 2>&1
"C:\Program Files\Unity 2019.3.6f1\Editor\Unity.exe" -quit -batchmode -serial %unitySerialToUse% -username %unityUsername% -password %unityPassword%
)
) ELSE (
REM Attempt to License Unity
PING 127.0.0.1 -n 5 >NUL 2>&1
"C:\Program Files\Unity 2019.3.6f1\Editor\Unity.exe" -quit -batchmode -serial %unitySerialToUse% -username %unityUsername% -password %unityPassword%
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment