@ECHO OFF
TITLE ÂÌ»¯
:init
setlocal DisableDelayedExpansion
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " "  >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B
:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul  &  shift /1)
taskkill /f /im AcmeCADConverter* 2
PUSHD %~DP0
if /i "%PROCESSOR_IDENTIFIER:~0,3%" == "X86" goto x86
if /i "%PROCESSOR_IDENTIFIER:~0,3%" NEQ "X86" goto x64
:x86
reg add "HKCU\Software\dwgtool\CADConverter\Language" /f /v LanguageFileName /d "SChinese.lan"
reg add "HKCU\Software\dwgtool\CADConverter\Register" /f /v RegistrationCode /d "D0OXJBQ3VW85R8I62X2SX7SLJ91065SHJGRG8QXGVZ2WYY9R8X06IJACYI8Z"
reg add "HKLM\SOFTWARE\dwgtool\CADConverter\Register" /f /v RegistrationCode /d "D0OXJBQ3VW85R8I62X2SX7SLJ91065SHJGRG8QXGVZ2WYY9R8X06IJACYI8Z"

:x64
reg add "HKCU\Software\dwgtool\CADConverter\Language" /f /v LanguageFileName /d "SChinese.lan"
reg add "HKCU\Software\dwgtool\CADConverter\Register" /f /v RegistrationCode /d "D0OXJBQ3VW85R8I62X2SX7SLJ91065SHJGRG8QXGVZ2WYY9R8X06IJACYI8Z"
reg add "HKLM\SOFTWARE\WOW6432Node\dwgtool\CADConverter\Register" /f /v RegistrationCode /d "D0OXJBQ3VW85R8I62X2SX7SLJ91065SHJGRG8QXGVZ2WYY9R8X06IJACYI8Z"

mshta VBScript:Execute("Set a=CreateObject(""WScript.Shell""):Set b=a.CreateShortcut(a.SpecialFolders(""Desktop"") & ""\Acme CAD Converter.lnk""):b.TargetPath=""%~dp0AcmeCADConverter.exe"":b.WorkingDirectory=""%~dp0"":b.Save:close")
exit