Skip to content
⌘ NSIS Forum Archive

Mistake in a script... I can not understand where...

3 posts

and84#

Mistake in a script... I can not understand where...

Hi all!
Has written a script with custom page...
Here a part of a script...
.... 
Page license 
Page custom CustomFun "" "" 
!insertmacro MUI_PAGE_INSTFILES 
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" 
ReserveFile "page.ini" 
!insertmacro MUI_LANGUAGE "Russian" 
Section "-Install" 
... 
SectionEnd 
Function .oninit 
         InitPluginsDir 
         File /oname=$PLUGINSDIR\page.ini "page.ini" 
Functionend 
Function CustomFun 
         !insertmacro MUI_HEADER_TEXT "TEXT1" "TEXT2" 
         !insertmacro INSTALLOPTIONS_INITDIALOG "page.ini" 
         !insertmacro INSTALLOPTIONS_SHOW 
FunctionEnd 
The section of installation is carried out two times. I can not understand why.
Probably I was mistaken in macros.

Help please.
Thanks!
and84#
Originally posted by pospec
You have to post a whole script if you want help.
All script...
!include "MUI.nsh"
!include "Locate.nsh"
Name "Setup"
OutFile "Setup.exe"
Caption 'Setup: Обновление'
SubCaption 0 " "
CRCCheck on
XPStyle on
MiscButtonText "Назад" "Вперед" "Прервать" "Готово"
InstallButtonText "Обновить"
ShowInstDetails show
CompletedText "Обновление завершено! Для завершения нажмите кнопку 'Готово'"
Var url
Var ip
Var lnk
Var ini_xz
Var ip_add
Var HWND1
Var DLGITEM
Var FONT
Page license 
Page custom SetCustom "" ""
!insertmacro MUI_PAGE_INSTFILES
Licensetext " " "Продолжить"
LicenseData "lic1.rtf"
LicenseBkColor /windows
LicenseForceSelection checkbox "Я прочитал соглашение и согласен с его условиями!"
ReserveFile "${NSISDIR}\\Plugins\\InstallOptions.dll"
ReserveFile "page.ini"
!insertmacro MUI_LANGUAGE "Russian"
Section "-init"
        StrCpy $url "Error"
        StrCpy $ip "OFF"
        StrCpy $lnk "OFF"
        ReadINIStr $ini_xz "$PLUGINSDIR\\page.ini" "Field 2" "State"
        StrCmp $ini_xz "1" 0 +3
        StrCpy $url "http://22.10.10.120/load"
        StrCpy $ip_add "22.10.10.120"
        ReadINIStr $ini_xz "$PLUGINSDIR\\page.ini" "Field 3" "State"
        StrCmp $ini_xz "1" 0 +3
        StrCpy $url "http://10.1.1.177/load"
        StrCpy $ip_add "10.1.1.177"
        ReadINIStr $ini_xz "$PLUGINSDIR\\page.ini" "Field 4" "State"
        StrCmp $ini_xz "1" 0 +3
        StrCpy $ip "OK"
        ReadINIStr $ini_xz "$PLUGINSDIR\\page.ini" "Field 12" "State"
        StrCmp $ini_xz "1" 0 +3
        StrCpy $lnk "OK"
SectionEnd
Section "-Install"
        StrCpy $2 "0"
        StrCmp $url "Error" 0 urlOK
        DetailPrint "Ошибка: Не определен параметр URL=$url(58x59x60x77x78)!"
        goto error
        urlOK:
        SetOutPath $EXEDIR
        DetailPrint "Соединение с сервером..."
        DetailPrint "Загрузка файл data.ini с сервера..."
        NSISdl::download /TRANSLATE "Загрузка файл data.ini с сервера..." "Соединение с сервером..." "сек." "мин." "ч." "c" "%d Кб (%d%%) из %d Кб -- %d.%01d Кб/с" " ( %d %s осталось )" "$url/data.ini" "$EXEDIR\data.ini"
        IfFileExists "$EXEDIR\\data.ini" +4
        goto error
        DetailPrint "Чтения файла..."
        next:
        IntOp $2 $2 + 1
        ReadINIStr $R1 '$EXEDIR\\data.ini' 'FILE $2' 'NAME'
        ReadINIStr $R2 '$EXEDIR\\data.ini' 'FILE $2' 'PATH'
        ReadINIStr $R3 '$EXEDIR\\data.ini' 'FILE $2' 'CRC'
        ReadINIStr $R4 '$EXEDIR\\data.ini' 'FILE $2' 'END'
        StrCmp $R2 "system" +3 0
        StrCmp $R2 "BASE" +2 0
        goto end
        IfFileExists "$EXEDIR\$R2\$R1" +2
        goto load
    CRCCheck::GenCRC "$EXEDIR\$R2\$R1"
        Pop $R0
        StrCmp $R0 $R3 end 0
        load:
        NSISdl::download /TRANSLATE "Загрузка файлов программы..." "Соединение с сервером..." "сек." "мин." "ч." "c" "%d Кб (%d%%) из %d Кб -- %d.%01d Кб/с" " ( %d %s осталось )" "$url/$R2/$R1" "$EXEDIR\$R2\$R1"
        end:
        StrCmp $R4 "END" 0 +3
        DetailPrint "Обновление завершено успешно!"
        goto quit
        goto next
        error:
        DetailPrint "Ошибка: Нет доступа к файлу!"
        DetailPrint "Обратитесь в тех. поддержку на форуме!"
        quit:
SectionEnd
Section "-host"
         StrCmp $ip "OFF" 0 +3
         DetailPrint "ВАЖНО! Необходимо натсроить Хост фаил..."
         Goto exit
         CopyFiles $SYSDIR\\drivers\\etc\\hosts $SYSDIR\\drivers\\etc\\hosts.bak
         FileOpen $0 $SYSDIR\\drivers\\etc\\hosts w
         DetailPrint "Автоматическая настройка хост файла..."
         FileWrite $0 "127.0.0.1              localhost$\n"
         FileWrite $0 "$ip_add         Info.DT.net$\n"
         FileWrite $0 "$ip_add         help.DT.net$\n"
         FileClose $0
         exit:
SectionEnd
Function .oninit
         System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
         Pop $0
         StrCmp $0 0 +3
         MessageBox MB_OK|MB_ICONEXCLAMATION "Setup.exe уже запущен!"
         Abort
         IfFileExists "$EXEDIR\system\RunDT.exe" +2
         MessageBox MB_ICONSTOP|MB_OK "Setup.exe необходимо запускать из папки программы DT!" IDOK +2
         MessageBox MB_USERICON|MB_YESNO|MB_DEFBUTTON1 "Обновить Ваш клиент?" IDYES +2
         Abort
         InitPluginsDir
         File /oname=$PLUGINSDIR\\page.ini "page.ini"
Functionend
Function SetCustom
         !insertmacro MUI_HEADER_TEXT "TEXT1" "TEXT2"
         !insertmacro INSTALLOPTIONS_INITDIALOG "page.ini"
         !insertmacro INSTALLOPTIONS_READ $DLGITEM "page.ini" "Field 1" "HWND" ; Выбор
                      CreateFont $FONT "Tahoma" 8 700
                      SendMessage $DLGITEM ${WM_SETFONT} $FONT 0
         !insertmacro INSTALLOPTIONS_READ $DLGITEM "page.ini" "Field 5" "HWND" ; Хост
                      CreateFont $FONT "Tahoma" 8 700
                      SendMessage $DLGITEM ${WM_SETFONT} $FONT 0
         !insertmacro INSTALLOPTIONS_READ $DLGITEM "page.ini" "Field 7" "HWND" ; П Нет
                      CreateFont $FONT "Tahoma" 8 300 /UNDERLINE
                      SendMessage $DLGITEM ${WM_SETFONT} $FONT 0
         !insertmacro INSTALLOPTIONS_READ $DLGITEM "page.ini" "Field 9" "HWND" ; П Ð_еал
                      CreateFont $FONT "Tahoma" 8 300 /UNDERLINE
                      SendMessage $DLGITEM ${WM_SETFONT} $FONT 0
         !insertmacro INSTALLOPTIONS_READ $DLGITEM "page.ini" "Field 6" "HWND"
                      CreateFont $FONT "Tahoma" 8 300 /UNDERLINE
                      SendMessage $DLGITEM ${WM_SETFONT} $FONT 0
         !insertmacro INSTALLOPTIONS_READ $DLGITEM "test.ini" "Field 2" "HWND"
                      CreateFont $FONT "Tahoma" 8 400
                      SendMessage $DLGITEM ${WM_SETFONT} $FONT 0
         !insertmacro INSTALLOPTIONS_SHOW
FunctionEnd
Function .onInstSuccess
         StrCmp $lnk "OK" 0 +2
         DetailPrint "Создание ярлыка на рабочем столе..."
         CreateShortCut "$DESKTOP\RunDT.lnk" "$EXEDIR\system\RunDT.exe" "" "$EXEDIR\system\DT.ico"
FunctionEnd 
Structure page.ini
[Settings]
NumFields=12
[Field 1]
Type=GroupBox
Left=0
Right=-1
Top=1
Bottom=-65
Text=" Натройки обновления... "
[Field 2]
Type=RadioButton
Text=Я из группы Home
Left=10
Right=-10
Top=14
Bottom=22
State=1
Flags=/NOTIFY
[Field 3]
Type=RadioButton
Text=Я из локальной сети DT
Left=10
Right=-10
Top=47
Bottom=57
State=0
Flags=/NOTIFY
[Field 4]
Type=checkbox
Text=Настроить хост-фаил
Left=10
Right=-10
Top=95
Bottom=105
State=1
Flags=NOTABSTOP
[Field 5]
Type=GroupBox
Left=0
Right=-1
Top=83
Bottom=-1
Text=" Дополнительно... "
[Field 6]
Type=Label
Left=25
Right=-230
Top=106
Bottom=116
Text=Примечание:
[Field 11]
Type=Label
Left=-227
Right=-5
Top=106
Bottom=116
Text=Ð_екомендуется автоматическая настройка.
[Field 7]
Type=Label
Left=28
Right=-230
Top=25
Bottom=35
Text=Примечание:
[Field 8]
Type=Label
Left=-227
Right=-5
Top=25
Bottom=45
Text=Для пользователями группы Home.
[Field 9]
Type=Label
Left=28
Right=-230
Top=58
Bottom=68
Text=Примечание:
[Field 10]
Type=Label
Left=-227
Right=-5
Top=58
Bottom=68
Text=Только для пользователей локальной сети.
[Field 12]
Type=checkbox
Text=Создать ярлык на рабочем столе.
Left=10
Right=-10
Top=121
Bottom=131
State=1
Flags=NOTABSTOP