Go NSIS: Determine the presence or absence of the D disk determines the installation path

Source: Internet
Author: User

Reprinted from: http://www.flighty.cn/html/bushu/20140704_239.html now we want to implement this feature:If the target machine has a D drive, install the program to D, or install it on the system disk. It was later added that the registry would use its key value as the installation path if an installation path key value existed. Ideas:By checking that the D disk has no disk space to judge, if the D drive does not exist, or if the D drive is an optical drive, the resulting disk space must be null. Example:
!include"Mui2.nsh"!include"Filefunc.nsh"Requestexecutionlevel AdminName"determine the presence or absence of the D disk determining the installation path"Caption"determine the presence or absence of the D disk determining the installation path"OutFile"Test.exe"InstallDir"$PROGRAMFILES \flighty App"read the installation path in the registration, and then follow the default path if it does not exist. Installdirregkey HKCU"software\flighty App" ""Brandingtext"www.flighty.cn"!insertmacro mui_page_directory!insertmacro mui_page_instfiles!insertmacro mui_language"Simpchinese"sectionsectionendsection-Post; Write the installation path in the registry Writeregstr HKCU"software\flighty App" ""$INSTDIRSectionEndFunction. OnInit readregstr $R 4 HKCU"software\flighty App" ""STRCMP $R 4""NO YES no:strcpy $R 1"d:\ "${drivespace} $R 1"/d=f/s=m"$R 0 ${if} $R 0=null StrCpy $R 1"$PROGRAMFILES \flighty App"${else} StrCpy $R 2"Program Files"StrCpy $R 3"flighty app"StrCpy $R 1"d:\ $R 2\ $R 3"${endif}; reset $instdir default value StrCpy $INSTDIR"$R 1"Yes:goto+1FunctionEnd

Go NSIS: Determine the presence or absence of the D disk determines the installation path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.