Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelp85/05ece28e3a959ffda008441774170dac to your computer and use it in GitHub Desktop.
Save michaelp85/05ece28e3a959ffda008441774170dac to your computer and use it in GitHub Desktop.
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