Код:
Var ac15
Var ac16
Var vart0
Var vart1
Var vart2
Var vart3
Var vart4
Var vart5
Var vart6
Var vart8
Var vart9
Var xtet
Var xtet2
!define Name "Addons for AutoCAD - ADD_ACAD"
Name "Addons for AutoCAD - ADD_ACAD"
;The file to write
OutFile "${Name}.exe"
Caption "${Name}"
InstallDir "$PROGRAMFILES\ADD_ACAD"

!include "MUI.nsh"
!include "LogicLib.nsh"

  !define MUI_LICENSEPAGE
  !define MUI_COMPONENTSPAGE
  !define MUI_COMPONENTSPAGE_SMALLDESC
  !define MUI_DIRECTORYPAGE
  !define MUI_ABORTWARNING
  !define MUI_UNINSTALLER
  !define MUI_UNCONFIRMPAGE
 
;--------------------------------
;Pages
  
  !insertmacro MUI_PAGE_LICENSE "License.txt"
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES
  
  !insertmacro MUI_LANGUAGE "Russian"

!ifdef uglyinstaller
BGGradient 000000 308030 FFFFFF
InstallColors FF8080 000000
InstProgressFlags smooth colored
!else
WindowIcon off
!endif
ShowInstDetails show
AutoCloseWindow false
;icon WinAmp.ico
SetDateSave off

Function .onInit

StrCpy $0 "0"
loop:
  EnumRegKey $1 HKLM "Software\Autodesk\AutoCAD\R15.0" $0
  StrCmp $1 "" done
  StrCmp $0 1 x1
  StrCmp $0 2 x2
  StrCmp $0 3 x3
  StrCmp $0 4 x4
StrCpy $R0 $1
goto next
x1:
StrCpy $R1 $1
goto next
x2:
StrCpy $R2 $1
goto next
x3:
StrCpy $R3 $1
goto next
x4:
StrCpy $R4 $1
next:
  IntOp $0 $0 + 1
  goto loop
done:

StrCpy $0 "0"
loop2:
  EnumRegKey $1 HKLM "Software\Autodesk\AutoCAD\R16.0" $0
  StrCmp $1 "" done2
  StrCmp $0 1 x6
  StrCmp $0 2 x7
StrCpy $R5 $1
goto next2
x6:
StrCpy $R6 $1
goto next2
x7:
StrCpy $R7 $1
next2:
  IntOp $0 $0 + 1
  goto loop2
done2:

StrCpy $0 "0"
loop3:
  EnumRegKey $1 HKLM "Software\Autodesk\AutoCAD\R16.1" $0
  StrCmp $1 "" done3
  StrCmp $0 1 x9
StrCpy $R8 $1
goto next3
x9:
StrCpy $R9 $1
next3:
  IntOp $0 $0 + 1
  goto loop3
done3:

  ReadRegStr $0 HKLM "Software\Autodesk\AutoCAD\R15.0\$R0" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R15.0\$R0" "Language"
    StrCpy $vart0 "$0 ($1)"

  ReadRegStr $0 HKLM "Software\Autodesk\AutoCAD\R15.0\$R1" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R15.0\$R1" "Language"
    StrCpy $vart1 "$0 ($1)"

  ReadRegStr $0 HKLM "Software\Autodesk\AutoCAD\R16.0\$R5" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R16.0\$R5" "Language"
    StrCpy $vart5 "$0 ($1)"

  ReadRegStr $0 HKLM "Software\Autodesk\AutoCAD\R16.0\$R6" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R16.0\$R6" "Language"
    StrCpy $vart6 "$0 ($1)"

  ReadRegStr $0 HKLM "Software\Autodesk\AutoCAD\R16.1\$R8" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R16.1\$R8" "Language"
    StrCpy $vart8 "$0 ($1)"

  ReadRegStr $0 HKLM "Software\Autodesk\AutoCAD\R16.1\$R9" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R16.1\$R9" "Language"
    StrCpy $vart9 "$0 ($1)"

FunctionEnd

Section "ADD ACAD (база)" 1
  SectionIn 1 2 RO
  SetOutPath $INSTDIR
file /x ".\ADD_ACAD\*.mn*" ".\ADD_ACAD\*" 
SectionEnd

Section /o "$vart0"
  StrCmp $vart0 "" +13 0

StrCpy $ac15 "yes"

  ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R15.0\$R0\Profiles" ""
  ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R15.0\$R0\Profiles\$xtet\General" "ACAD"
    StrCpy $R2 "$R2$INSTDIR;"
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R15.0\$R0\Profiles\$xtet\General" "ACAD" "$R2"
    StrCpy $R1 0
${Do}
    IntOp $R1 $R1 + 1
  ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R15.0\$R0\Profiles\$xtet\Menus" "Group$R1"
  StrCmp $xtet2 "" 0 +3
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R15.0\$R0\Profiles\$xtet\Menus" "Group$R1" "ADD_ACAD $INSTDIR\ADD_ACAD"
    ${ExitDo}
${Loop}

SectionEnd

Section /o "$vart1"
  StrCmp $vart1 "" +13 0

StrCpy $ac15 "yes"

  ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R15.0\$R1\Profiles" ""
  ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R15.0\$R1\Profiles\$xtet\General" "ACAD"
    StrCpy $R2 "$R2$INSTDIR;"
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R15.0\$R1\Profiles\$xtet\General" "ACAD" "$R2"
    StrCpy $R1 0
${Do}
    IntOp $R1 $R1 + 1
  ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R15.0\$R1\Profiles\$xtet\Menus" "Group$R1"
  StrCmp $xtet2 "" 0 +3
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R15.0\$R1\Profiles\$xtet\Menus" "Group$R1" "ADD_ACAD $INSTDIR\ADD_ACAD"
    ${ExitDo}
${Loop}

SectionEnd

Section /o "$vart5"
  StrCmp $vart5 "" +13 0

StrCpy $ac16 "yes"

  ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles" ""
  ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\General" "ACAD"
    StrCpy $R2 "$R2$INSTDIR;"
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\General" "ACAD" "$R2"
    StrCpy $R1 0
${Do}
    IntOp $R1 $R1 + 1
  ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\Menus" "Group$R1"
  StrCmp $xtet2 "" 0 +3
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\Menus" "Group$R1" "ADD_ACAD $INSTDIR\ADD_ACAD_4"
    ${ExitDo}
${Loop}

SectionEnd

Section /o "$vart6"
  StrCmp $vart6 "" +13 0

StrCpy $ac16 "yes"

  ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.0\$R6\Profiles" ""
  ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R6\Profiles\$xtet\General" "ACAD"
    StrCpy $R2 "$R2$INSTDIR;"
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R6\Profiles\$xtet\General" "ACAD" "$R2"
    StrCpy $R1 0
${Do}
    IntOp $R1 $R1 + 1
  ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R6\Profiles\$xtet\Menus" "Group$R1"
  StrCmp $xtet2 "" 0 +3
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R6\Profiles\$xtet\Menus" "Group$R1" "ADD_ACAD $INSTDIR\ADD_ACAD_4"
    ${ExitDo}
${Loop}

SectionEnd

Section /o "$vart8"
  StrCmp $vart8 "" +13 0

StrCpy $ac16 "yes"

  ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.1\$R8\Profiles" ""
  ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R8\Profiles\$xtet\General" "ACAD"
    StrCpy $R2 "$R2$INSTDIR;"
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R8\Profiles\$xtet\General" "ACAD" "$R2"
    StrCpy $R1 0
${Do}
    IntOp $R1 $R1 + 1
  ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R8\Profiles\$xtet\Menus" "Group$R1"
  StrCmp $xtet2 "" 0 +3
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R8\Profiles\$xtet\Menus" "Group$R1" "ADD_ACAD $INSTDIR\ADD_ACAD_4"
    ${ExitDo}
${Loop}

SectionEnd

Section /o "$vart9"
  StrCmp $vart9 "" +13 0

StrCpy $ac16 "yes"

  ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.1\$R9\Profiles" ""
  ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R9\Profiles\$xtet\General" "ACAD"
    StrCpy $R2 "$R2$INSTDIR;"
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R9\Profiles\$xtet\General" "ACAD" "$R2"
    StrCpy $R1 0
${Do}
    IntOp $R1 $R1 + 1
  ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R9\Profiles\$xtet\Menus" "Group$R1"
  StrCmp $xtet2 "" 0 +3
  WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R9\Profiles\$xtet\Menus" "Group$R1" "ADD_ACAD $INSTDIR\ADD_ACAD_4"
    ${ExitDo}
${Loop}

SectionEnd

Section -post

StrCmp $ac15 "yes" 0 +3 
delete "$INSTDIR\ADD_ACAD.mn*"
file .\ADD_ACAD\ADD_ACAD.mn*

StrCmp $ac16 "yes" 0 +3 
delete "$INSTDIR\ADD_ACAD_4.mn*"
file .\ADD_ACAD\ADD_ACAD_4.mn*

SectionEnd