How to write the registry creation in the the install script in .nsi file

Dineshkumar.S 456 Reputation points
2023-08-14T07:31:40.4+00:00

I want to add a new registry in HKCU IN the user system for that I need to add a script in the installer script file which means .nsi file how to write a script for adding a new registry creation can anyone tell me the step-by-step procedure or else sample code to write the script and I have added my registry details below for the reference. It will be very helpful and Thanks in advance.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\blimey]

@="URL:Alert Protocol"

"URL Protocol"=""

[HKEY_CURRENT_USER\SOFTWARE\Classes\blimey\shell]

[HKEY_CURRENT_USER\SOFTWARE\Classes\blimey\shell\open]

[HKEY_CURRENT_USER\SOFTWARE\Classes\blimey\shell\open\command]

@=""C:\Users\hp\Documents\GitHub\blimey-tool\EYE.Learn\bin\x64\Debug\Blimey.exe" "%1""

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,908 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,681 Reputation points
    2023-08-15T13:15:09.44+00:00
    Hello there,
    
    To add a new registry entry during the installation of your Windows application using NSIS (Nullsoft Scriptable Install System), you can follow these steps:
    
    Open your NSIS script file (usually with a .nsi extension) in a text editor.
    
    Locate the section in the script where the installation process is defined. This is typically the "Section" section.
    
    Inside the "Section" section, you can add a new registry entry using the WriteRegStr, WriteRegDWORD, or other registry-related NSIS commands depending on the type of registry entry you want to create. Here's an example:
    
    nsis
    Copy code
    Section "MyApplication"
      SetOutPath "$INSTDIR" ; Set the installation directory
    
      ; Add a new registry entry
      WriteRegStr HKLM "Software\MyCompany\MyApplication" "MySetting" "MyValue"
    
      ; ... Other installation commands
    
    SectionEnd
    In the example above, the WriteRegStr command is used to create a new string value in the HKEY_LOCAL_MACHINE\Software\MyCompany\MyApplication registry key. Replace "MyCompany", "MyApplication", "MySetting", and "MyValue" with your desired values.
    
    Save the NSIS script file.
    
    Build or compile your NSIS script using the NSIS compiler. This will generate an executable installer for your application that includes the registry entry.
    
    When the installer is executed, it will create the specified registry entry during the installation process. Make sure to run the installer with administrative privileges to ensure the necessary permissions for modifying the registry.
    
    Similar discussion here https://learn.microsoft.com/en-us/answers/questions/1299645/how-to-write-nsi-script-for-a-windows-application
    
    Hope this resolves your Query !!
    
    --If the reply is helpful, please Upvote and Accept it as an answer–
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.