Код:
Var YN
Var ac15
Var ac16
Var ac17
Var CS
Var vart0
Var vart1
Var vart2
Var vart3
Var vart4
Var vart5
Var vart6
Var vart7
Var vart8
Var vart9
Var xtet
Var xtet2
!define TEMP $R0
!define Name "Addons for AutoCAD - СДПС 3.0.311"
Name "Addons for AutoCAD - СДПС 3.0.311"
;The file to write
OutFile "..\${Name}.exe"
Caption "${Name}"
InstallDir $PROGRAMFILES\ADD_ACAD2

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

  !define MUI_CUSTOMPAGECOMMANDS

  !define MUI_LICENSEPAGE
  !define MUI_COMPONENTSPAGE
  !define MUI_COMPONENTSPAGE_SMALLDESC
;  !define MUI_DIRECTORYPAGE
  !define MUI_ABORTWARNING
 
;--------------------------------
;Pages

  !insertmacro MUI_PAGE_LICENSE "License.txt"
  !insertmacro MUI_PAGE_COMPONENTS
  !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

  ReadRegStr $CS HKLM "SOFTWARE\Consistent Software\СПДС GraphiCS\3.0" "APPPath"
  StrCmp $CS "" 0 +3
	MessageBox MB_OK|MB_ICONSTOP "СПДС Grafics 3.0 на ПК не обнаружен!"
	Abort

StrCpy $INSTDIR "$CS\Path"

StrCpy $0 "0"
loop:
  EnumRegKey $1 HKLM "Software\Autodesk\AutoCAD\R15.0" $0
  StrCmp $1 "" done
  StrCmp $0 1 x1
  StrCmp $0 2 x2
StrCpy $R0 $1
goto next
x1:
StrCpy $R1 $1
goto next
x2:
StrCpy $R2 $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 x4
  StrCmp $0 2 x5
StrCpy $R3 $1
goto next2
x4:
StrCpy $R4 $1
goto next2
x5:
StrCpy $R5 $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 x7
StrCpy $R6 $1
goto next3
x7:
StrCpy $R7 $1
next3:
  IntOp $0 $0 + 1
  goto loop3
done3:

StrCpy $0 "0"
loop4:
  EnumRegKey $1 HKLM "Software\Autodesk\AutoCAD\R16.2" $0
  StrCmp $1 "" done4
  StrCmp $0 1 x9
StrCpy $R8 $1
goto next4
x9:
StrCpy $R9 $1
next4:
  IntOp $0 $0 + 1
  goto loop4
done4:

  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\R15.0\$R2" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R15.0\$R2" "Language"
    StrCpy $vart2 "$0 ($1)"

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

  ReadRegStr $0 HKLM "Software\Autodesk\AutoCAD\R16.0\$R4" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R16.0\$R4" "Language"
    StrCpy $vart4 "$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.1\$R6" "ProductName"
    StrCmp $0 "" +3 0
  ReadRegStr $1 HKLM "Software\Autodesk\AutoCAD\R16.1\$R6" "Language"
    StrCpy $vart6 "$0 ($1)"

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

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

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

FunctionEnd

Section "СПДС 3.0.311 (база)" 1
  SectionIn 1 2 RO
  SetOutPath $INSTDIR
file /x settings.xml /x *.mn* ".\SPDS3.0.311\*"
file "help.chm"
  SetOutPath $INSTDIR\..\data
;file ".\SPDS3.0.311\settings.xml"
SectionEnd

Section "$vart0"
  StrCmp $vart0 "" +20 0
      StrCpy $vart0 "$vart0+"
        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"
    Push "$R2"
    Push "$CS\m4;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3
	StrCpy $R2 "$R2$CS\m4;$CS\DataRO\Fonts;$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" "SPDS30 $INSTDIR\SPDS30"
	${ExitDo}
	${Loop}

SectionEnd

Section "$vart1"
  StrCmp $vart1 "" +20 0
      StrCpy $vart1 "$vart1+"
        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"
    Push "$R2"
    Push "$CS\m4;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3
	StrCpy $R2 "$R2$CS\m4;$CS\DataRO\Fonts;$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" "SPDS30 $INSTDIR\SPDS30"
	${ExitDo}
	${Loop}

SectionEnd

Section "$vart3"
  StrCmp $vart3 "" +25 0
      StrCpy $vart3 "$vart3+"
        StrCpy $ac16 "yes"

    ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles" ""
    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles\$xtet\General" "ACAD"
    Push "$R2"
    Push "$CS\m7;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3
	StrCpy $R2 "$R2$CS\m7;$CS\DataRO\Fonts;$INSTDIR;"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles\$xtet\General" "ACAD" "$R2"

    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup"
    IntOp $R2 $R2 + 1
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup" "$R2"
	StrCpy $R2 "$R2Startup"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles\$xtet\Dialogs\Appload\Startup" "$R2" "$CS\m7\mcsLoader.arx"

	StrCpy $R1 0
	${Do}
    IntOp $R1 $R1 + 1
    ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles\$xtet\Menus" "Group$R1"
    StrCmp $xtet2 "" 0 +3
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R3\Profiles\$xtet\Menus" "Group$R1" "SPDS30 $INSTDIR\SPDS30_4"
	${ExitDo}
	${Loop}

SectionEnd

Section "$vart4"
  StrCmp $vart4 "" +25 0
      StrCpy $vart4 "$vart4+"
        StrCpy $ac16 "yes"

    ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles" ""
    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles\$xtet\General" "ACAD"

    Push "$R2"
    Push "$CS\m7;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3

	StrCpy $R2 "$R2$CS\m7;$CS\DataRO\Fonts;$INSTDIR;"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles\$xtet\General" "ACAD" "$R2"

    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup"
    IntOp $R2 $R2 + 1
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup" "$R2"
	StrCpy $R2 "$R2Startup"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles\$xtet\Dialogs\Appload\Startup" "$R2" "$CS\m7\mcsLoader.arx"

	StrCpy $R1 0
	${Do}
    IntOp $R1 $R1 + 1
    ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles\$xtet\Menus" "Group$R1"
    StrCmp $xtet2 "" 0 +3
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R4\Profiles\$xtet\Menus" "Group$R1" "SPDS30 $INSTDIR\SPDS30_4"
	${ExitDo}
	${Loop}

SectionEnd

Section "$vart5"
  StrCmp $vart5 "" +25 0
      StrCpy $vart5 "$vart5+"
        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"

    Push "$R2"
    Push "$CS\m7;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3

	StrCpy $R2 "$R2$CS\m7;$CS\DataRO\Fonts;$INSTDIR;"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\General" "ACAD" "$R2"

    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup"
    IntOp $R2 $R2 + 1
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup" "$R2"
	StrCpy $R2 "$R2Startup"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.0\$R5\Profiles\$xtet\Dialogs\Appload\Startup" "$R2" "$CS\m7\mcsLoader.arx"

	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" "SPDS30 $INSTDIR\SPDS30_4"
	${ExitDo}
	${Loop}
SectionEnd

Section "$vart6"
  StrCmp $vart6 "" +25 0
      StrCpy $vart6 "$vart6+"
        StrCpy $ac16 "yes"

    ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles" ""
    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles\$xtet\General" "ACAD"

    Push "$R2"
    Push "$CS\m7;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3

	StrCpy $R2 "$R2$CS\m7;$CS\DataRO\Fonts;$INSTDIR;"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles\$xtet\General" "ACAD" "$R2"

    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup"
    IntOp $R2 $R2 + 1
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup" "$R2"
	StrCpy $R2 "$R2Startup"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles\$xtet\Dialogs\Appload\Startup" "$R2" "$CS\m7\mcsLoader.arx"

	StrCpy $R1 0
	${Do}
    IntOp $R1 $R1 + 1
    ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles\$xtet\Menus" "Group$R1"
    StrCmp $xtet2 "" 0 +3
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R6\Profiles\$xtet\Menus" "Group$R1" "SPDS30 $INSTDIR\SPDS30_4"
	${ExitDo}
	${Loop}
SectionEnd

Section "$vart7"
  StrCmp $vart7 "" +25 0
      StrCpy $vart7 "$vart7+"
        StrCpy $ac16 "yes"

    ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles" ""
    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles\$xtet\General" "ACAD"

    Push "$R2"
    Push "$CS\m7;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3

	StrCpy $R2 "$R2$CS\m7;$CS\DataRO\Fonts;$INSTDIR;"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles\$xtet\General" "ACAD" "$R2"

    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup"
    IntOp $R2 $R2 + 1
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles\$xtet\Dialogs\Appload\Startup" "NumStartup" "$R2"
	StrCpy $R2 "$R2Startup"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles\$xtet\Dialogs\Appload\Startup" "$R2" "$CS\m7\mcsLoader.arx"

	StrCpy $R1 0
	${Do}
    IntOp $R1 $R1 + 1
    ReadRegStr $xtet2 HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles\$xtet\Menus" "Group$R1"
    StrCmp $xtet2 "" 0 +3
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.1\$R7\Profiles\$xtet\Menus" "Group$R1" "SPDS30 $INSTDIR\SPDS30_4"
	${ExitDo}
	${Loop}

SectionEnd

Section "$vart8"
  StrCmp $vart8 "" +13 0
      StrCpy $vart8 "$vart8+"
        StrCpy $ac16 "yes"
        StrCpy $ac17 "yes"

    ReadRegStr $xtet HKCU "Software\Autodesk\AutoCAD\R16.2\$R8\Profiles" ""
    ReadRegStr $R2 HKCU "Software\Autodesk\AutoCAD\R16.2\$R8\Profiles\$xtet\General" "ACAD"

    Push "$R2"
    Push "$CS\m7;$CS\DataRO\Fonts;$INSTDIR"
    Call StrStr
    Pop $YN
    StrCmp $YN "" 0 +3

	StrCpy $R2 "$R2$CS\m7;$CS\DataRO\Fonts;$INSTDIR;"
    WriteRegStr HKCU "Software\Autodesk\AutoCAD\R16.2\$R8\Profiles\$xtet\General" "ACAD" "$R2"

SectionEnd

Section /o "Показать справку"

    ExecShell open '$INSTDIR\Help.chm'

SectionEnd

Section -post

SetOutPath $INSTDIR

StrCmp $ac15 "yes" 0 +3 
delete "$INSTDIR\SPDS40.mn*"
file ".\SPDS3.0.311\SPDS30.mn*"

StrCmp $ac16 "yes" 0 +3 
delete "$INSTDIR\SPDS30_4.mn*"
file ".\SPDS3.0.311\SPDS30_4.mn*"

StrCmp $ac17 "yes" 0 +3
delete "$INSTDIR\SPDS30_4.cui"

StrCmp $vart3 "AutoCAD 2004 (Русский)+" 0 +2
Exec 'AutoIt3_K.exe AutoCAD2004.au3'

StrCmp $vart4 "AutoCAD 2004 (Русский)+" 0 +2
Exec 'AutoIt3_K.exe AutoCAD2004.au3'

StrCmp $vart5 "AutoCAD 2004 (Русский)+" 0 +2
Exec 'AutoIt3_K.exe AutoCAD2004.au3'

StrCmp $vart8 "AutoCAD 2006 (Русский)+" 0 +2
Exec 'AutoIt3_K.exe AutoCAD2006.au3'

SectionEnd

;==============================================================

Function StrStr
   Exch $R1 ; st=haystack,old$R1, $R1=needle
   Exch    ; st=old$R1,haystack
   Exch $R2 ; st=old$R1,old$R2, $R2=haystack
   Push $R3
   Push $R4
   Push $R5
   StrLen $R3 $R1
   StrCpy $R4 0
   ; $R1=needle
   ; $R2=haystack
   ; $R3=len(needle)
   ; $R4=cnt
   ; $R5=tmp
   loop:
     StrCpy $R5 $R2 $R3 $R4
     StrCmp $R5 $R1 done
     StrCmp $R5 "" done
     IntOp $R4 $R4 + 1
     Goto loop
 done:
   StrCpy $R1 $R2 "" $R4
   Pop $R5
   Pop $R4
   Pop $R3
   Pop $R2
   Exch $R1
 FunctionEnd