Q: If you press "cancel" during the installation process, the confirmation window for terminating the installation will pop up. How can I set this window so that it will not appear? Can I simply exit after "cancel?
A :! Define mui_abortwarning can remove this sentence ....
Q: What is displayed now is "setup will install...". Apart from using custom strings to modify this location, how can I make this setup into something else? For example, "the installer will ..."
A: The dirtext installer will install $ (^ nameda) in the following folders. To install it in different folders, click [browse (B)] and select another folder. $ _ Click"
Figure:
Q: How to define the title Font size on the welcome page. As shown in, Figure 3 shows the title Font in the red box.
A: Use the following script:
! Define mui_page_customfunction_show chagefont
! Insertmacro mui_page_welcome
Function chagefont
Getdlgitem $0 $ mui_hwnd 1201
Createfont $1 "tahoma" "11" "700"
Sendmessage $0 $ {wm_setfont} $1 0
Functionend
Figure:
Q: Add a version number.
Viproductversion "1.2.3.4"
Viaddversionkey/lang =$ {lang_english} "productname" "test application"
Viaddversionkey/lang =$ {lang_english} "Comments" "A test comment"
Viaddversionkey/lang =$ {lang_english} "companyName" "fake company"
Viaddversionkey/lang =$ {lang_english} "legaltrademarks" "test application is a trademark of fake company"
Viaddversionkey/lang =$ {lang_english} "legalcopyright ""? Fake Company"
Viaddversionkey/lang =$ {lang_english} "filedescription" "test application"
Viaddversionkey/lang =$ {lang_english} "fileversion" "1.2.3"
Add the above Code to the script to add version information to the EXE generated by NSIs.
The question is, can the attribute language be displayed as "Chinese (China )"? As shown in figure 1
A: The Chinese ID is 2052. Change $ {lang_english} To 2052.
Q: It turns into "Chinese (China)" after 2052. However, other content is still garbled. Do you have any solutions? As shown in figure 2
A: The version information setting statement is placed in! After insertmacro mui_language, NSIs should focus on order. If you use the classical interface, place it behind loademediagefile "$ {nsisdir}/contrib/language files/simpchinese. NLF.
Figure:
Q: How can I disable the banner shown in the figure.
A: The figure below shows the effect when the installer is initialized. when the oninit function needs to use a file, the installer needs to search for the entire data block to decompress it. When the installer is large, it takes a long time to search, and the decompression percentage is displayed. Generally, reservefile is used to avoid such searches.
For example, in function. oninit
Initpluginsdir
File "/oname = $ pluginsdir/IO. ini" "./IO. ini"
Or, if it is similar, the installer needs to search for and decompress the file.
Generally, it is added to the script header.
Reservefile "./IO. ini"
In this way, Io. INI is stored at the end of the data block, and you do not need to search for the entire data block during installation initialization, which is equivalent to accelerating the startup of the installation program.
Q: The initialization dialog box is no longer displayed after the above method is used. However, before the custom installoptions page is displayed, the program will pause for a while. Why? How to avoid it?
A: Some controls consume time, such as display icons and bitmaps. If installoptions contains these controls, they may pause. If installoptions is the first page, add installoptions. DLL to the reservefile parameter. Or, when entering installoptions, it contains complicated commands, such as loops.
Generally, you can avoid adding reservefile $ {nsisdir}/plugins/installoptions. dll.
Figure:
Q: How to run an installation file. inf
A: execwait "rundll32 advpack. dll, launchinfsection skins. inf, defaultinstall"
Q: The associated file icon remains unchanged.
A: Use the refresh icon. System: Call shell32.dll: shchangenoworkflow (l, l, I, I) V (0x08000000, 0, 0, 0)
Q: I have prepared an installation program with NSIs. Because there is a large amount of data, there are a total of more than 400 m. The lzma compression method is used. After the installation program is completed, it will be about 200 m, however, I found that when running this installer, a temporary file with the same content as after the installation will be generated in the temp directory of the system (the file is increased while running, at last, I went to over 400 m.) If the program I made is too small, but there are more than 400 m programs, in addition to the data to be written to and installed, it is too difficult to store temporary files in the same size of space,
I would like to ask: Is there any way to prevent such a large amount of temporary space from being used during installation? The installation script is generated using the wizard of hm nis edit.
A: This is because NSIs adopts solid compression when using lzma. What is solid compression? In fact, it is to unify all files and compress them. Therefore, the files compressed in this way are smaller, it also brings about a problem. during installation and decompression, a temporary file is generated in the Temporary Folder. As the installation process increases, the size of the temporary file is the same as that of the original Installer. That is to say, it takes twice the space of the original installer to install the program. Therefore, this is not suitable for installing a large number of files.
Earlier than NSIs 2.07, the lzma algorithm is solid-state compression and does not have any non-solid-state options. To do so, only download the non-solid-state compression compiler, however, the lzma compression of NSIs after 2.07 has been changed to non-solid compression by default, so this problem does not exist at the same time. If you still want to use solid compression when creating a small number of files, you can add the/solid parameter. Like this: setcompressor/solid lzma
Q: Can I read the INI File status in the section Section for installation.
If option 1 is selected, install the file defined in option 1. If not selected, it is not installed. If option 2 is selected, the file defined in Option 2 is installed. If this parameter is not selected, it is not installed.
A: Use the following code,
! Include logiclib. nsh
Section-post
Setoutpath $ instdir
! Insertmacro mui_installoptions_read $ ini_value "info. ini" "Field 2" "state"
$ {If} $ ini_value = 1
File/a "./file/filea.exe"
File/a "./file/fileb.exe"
$ {Endif}
! Insertmacro mui_installoptions_read $ ini_value "info. ini" "Field 3" "state"
$ {If} $ ini_value = 1
File/a "./file/filea.exe"
$ {Endif}
Sectionend
Or use the following code,
! Include logiclib. nsh
Section-post
Setoutpath $ instdir
! Insertmacro mui_installoptions_read $ ini_value "info. ini" "Field 2" "state"
$ {If} $ ini_value = 1
; Code executed when selected
File/a "./file/filea.exe"
File/a "./file/fileb.exe"
$ {Else}
; Indicates the code that is executed when no value is selected.
File/a "./file/filea.exe"
$ {Endif}
Sectionend
Figure:
Q: How to set a working directory in NSIs, such as the shortcut of some files, and run a program after installing a software, which needs to detect a file in the current working directory, setting the working directory is particularly important at this time, otherwise the program cannot run normally.
A: setoutpath is used to set the working directory in NSIs. For example, if setoutpath $ instdir is placed before the Code execwait "$ instdir/test2.exe" of the running program, $ instdir will become the current working directory, if you create a shortcut, the working directory is set to $ instdir.
Before running a program, you only need to put the running command in function UN. oninit.
Q: I have seen a post about how to call the. inf file in NSIs to install the additional driver. The specific implementation code is as follows:
Execwait "rundll32 advpack. dll, launchinfsection drivers. inf, defaultinstall"
I used this method when packaging a small Dongdong, but what if I had to set in the unload section to automatically uninstall the installed driver?
A: whether the file can be detached depends on whether the INF file contains the unmounted section. For example, if you use NSIs to uninstall Windows Messenger, you can:
Execwait "rundll32 advpack. dll, launchinfsection $ WINDIR/INF/MSMSGS. inf, BLC. Remove"
For the source of BLC. Remove, you can open the MSMSGS. inf file and find the section named BLC. Remove, which is used for uninstallation. The section name is customized by the creator. Different INF files may have different region names.
Other *. INF files can also follow this approach.
Q: 1. I have created an installer that can be executed in simplified Chinese. But there is a lot of confusion.
At the beginning, I made a Simplified Chinese version. Of course, there is no problem in the simplified version, but in English/traditional versions, the Group Name of the Chinese program created and the garbled code displayed when writing the registry. So I thought of writing an installation program suitable for all three.
This is my practice. When it comes to creating a Chinese program group and writing a registry, add a judgment. If it is in English or traditional Chinese, create an English file name and a big5 internal code file name respectively. However, after testing in the traditional Windows XP and English win2ks' architecture, the uninstall.exe file cannot be created normally. The Chinese characters written into the registry cannot be normally displayed in the registry of the traditional Chinese system, but are garbled.
How can I handle this problem in a multi-language environment to display it properly? Cannot all be created in English?
2. There is also a small problem. How can I make the NSIs installation program not show the specific installation file name, but only show "copying files ......"? Like foobar, it is a pity that foobar also has a button to show details. I don't want to display or prompt the file to be copied during file copying.
Answer: 1. The simplest solution is to define the resources to be processed and use langstring to define different resources. Example:
Caption "$ (Caption )"
Langstring caption $ {1033} "dreammail installation"
Langstring caption $ {2052} "dreammail Installation Wizard"
Langstring caption $ {1028} "dreammail lever old"
2. You can use detailprint, for example,
Detailprint "copying file ..."
Q: What are the requirements for the ICO Icon size for NSIs installation and uninstallation? The following error message is prompted during compilation,
Error finding ICON resources: installer, uninstaller Icon size mismatch-see the icon instructions documentation for more information -- failing!
A: ensure that the size of the installation icon is the same as that of the uninstall icon.
Q: How can I block setup verification in the example.
Answer: crccheck on | off | force
Specifies whether the installer executes a CRC for itself before installation. Note: If you use the/NCRC command line parameter and you do not specify the force parameter, CRC is not executed, which may cause you to install a corrupted installer.
The installation program CRC check is enabled by default. Crccheck off can be used in the script to disable CRC verification of the installer by default. However, as explained above, installation may cause problems. It is best to add verification in Chinese to avoid the problem of installation program becoming the problem of Chinese quality.
Figure:
Q: Can I select multiple languages during installation? But how can I install the English version when I select English, and the Chinese version when I select Chinese?
A: Use the following script,
Strcmp $ language $ {lang_simpchinese} 0 + 3
File "Chinese files to be installed"
Goto lbl_finish
File "The English file you need to install"
Lbl_finish:
Q: component a component B component C is optional. A can be installed independently. When B or C is selected, a must be selected.
A: The following code is used,
Section "component A" aaa
Detailprint ""
Sectionend
Section "component B" bbb
Detailprint "B"
Sectionend
Section "component C" CCC
Detailprint "C"
Sectionend
Function. onselchange
Sectiongetflags $ {BBB} $0
Sectiongetflags $ {CCC} $1
Intop $0 $0 & 1
Intop $1 $1 & 1
Intcmp $0 1 0 + 2
Sectionsetflags $ {AAA} 1
Intcmp $1 1 0 + 2
Sectionsetflags $ {AAA} 1
Functionend
Explanation: sectiongetflags indicates to obtain the flags status of a certain segment (that is, whether it is checked, the selected return value is 1, and the reverse value is 0)
Sectiongetflags $ {BBB} $0 indicates to obtain the flags status of the Section with the serial number $ {BBB} and output the returned value to the variable $0, with the same C segment.
The next step is strcmp.
Sectionsetflags $ {AAA} 1 indicates that the flags status of the section No. $ {AAA} is set to 1, which is checked.
Q: If this is the case, the header bitmap can be displayed on the left.
! Define mui_abortwarning
! Define mui_icon "$ {nsisdir}/contrib/graphics/icons/modern-install.ico"
! Define mui_unicon "$ {nsisdir}/contrib/graphics/icons/modern-uninstall.ico"
! Define mui_headerimage
! Define mui_headerimage_bitmap "F:/11.bmp"
Shown in Figure 1. The installation icon is displayed on the left, but if mui_headerimage is changed to mui_headerimage_right, the bitmap cannot be displayed, as shown in figure 2.
A: place the inserted headerimage to the right (left by default)
! Define mui_headerimage
! Define mui_headerimage_right
! Define mui_headerimage_bitmap "include/resource/modern-header.bmp"
Not the modification you mentioned! Define mui_headerimage should be added under this sentence! Define mui_headerimage_right
Figure 1:
Figure 2:
Q: How can I change the title bar of the "License Agreement" Page, such as the "mutlipages Demo" in the program to "mutlipages Demo: License Agreement", as shown in the figure below.
A: Create a function as follows.
Function licensepagepre
Sendmessage $ hwndparent $ {wm_settext} 0 "str: I love you"
Functionend
Then sentence on the Protocol page
! Insertmacro mui_page_license "C:/path/to/Licence/yoursoftwarelicence.txt"
Add the following statement
! Define mui_page_customfunction_pre licensepagepre
Figure:
Q: for example, I packed a.exe with NSIs and installed it in C:/hellolib/a.exe. After that, I want to add C:/hellolib/to the path of the system environment variable, in this way, enter a.exe anywhere to execute. How do I add a path to a system environment variable?
A: The following code is used:
Readregstr $0 HKLM "system/CurrentControlSet/control/Session Manager/environment" "path"
Writeregexpandstr HKLM "system/CurrentControlSet/control/Session Manager/environment" "path" $0; C:/hellolib"
Alternative Method 1: Write the registry, such
[Hkey_classes_root/applications/a.exe/Shell/Open/command]
@ = "Yourpath/a.exe"
Alternative Method 2:
[HKEY_LOCAL_MACHINE/software/Microsoft/Windows/CurrentVersion/APP paths/a.exe]
@ = "C:/hellolib/a.exe"
Q: In NSIs, how can I determine whether to write a string based on the key value of the registry? If a key exists, the corresponding string is written. If no key exists, no string is written. For example, you must first determine whether the key "HKLM software/NSIs" does not exist. If "dispname: NSIs" is written, "writeregstr HKLM" software/NSIs "" dispname "" NSIs "" is used "". If this key does not exist, it is not written to the Registry. Continue the installation below.
A: The following code is implemented,
Readregstr $0 HKLM software/NSIs ""
Iferrors 0 + 2
Goto + 2
Writeregstr HKLM "software/NSIs" "dispname" "NSIs"
Q: When creating an installation package, you need to call a system function to check the inner code page of the operating system running the current installation package.
A: The following code displays the system language.
System: Call "Kernel32: getsystemdefaultlangid (V ..) I. s"
Pop $0
Intop $0 $0 & 0 xFFFF
MessageBox mb_ OK $0
Q: How do I use NSIs to register fonts?
A: The following code is used,
! Include winmessages. nsh
Section "mainsection" sec01
File/oname = $ fonts/tahoma. TTF tahoma. TTF
Push "$ fonts/tahoma. TTF"
System: Call "GDI32: addfontresource (t s) I. s"
Pop $0
Intcmp $0 0 + 2 + 2
MessageBox mb_ OK "font registration failed"
Sendmessage $ {hwnd_broadcast }$ {wm_fontchange} 0 0
Sectionend
Q: How to Use NSIs installation input method.
A: The following code is used,
Setoutpath $ Sysdir
File wbime. ime
Push "five input methods"
Push "$ Sysdir/wbime. ime"
System: Call "imm32: imminstallime (t s, t s) I. s"
System: Call "imm32: immisime (I s) I. s"
Pop $0
Intcmp $0 1 0 + 3 + 3
MessageBox mb_ OK "Input Method installed successfully"
Goto + 2
MessageBox mb_ OK "Input Method Installation failed"