Set the check state of the task to match the current startup state (if upgrading) - inno-setup

My software installer allows the user to start the application when the user logs in. It does that like this:
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; \
ValueType: string; ValueName: "appname"; ValueData: "{app}\appname.exe"; \
Tasks: startup
It is based on the answer here (https://stackoverflow.com/a/40147393/2287576). But the software itself allows the user to modify the start-up state (by programmatically adding/removing the same registry data).
How can I adjust the Inno Setup Script to detect if:
It is upgrading and
If it is already in the Startup list
I would like the check state of the task to match the current startup state (if upgrading)

Related

What happens in Inno Setup uninstaller to Registry keys without flags?

If I have following line in my [Registry] section of my Inno Setup script
Root: "HKLM"; Subkey: "SOFTWARE\MySoftware"; ValueType: string; \
ValueName: "ApplicationDescription"; ValueData: "My cool software";
what will happen when uninstalling? Do I need to add flags: uninsdeletevalue; if it should be removed on uninstall?
As explicitly written in [Registry] section documentation:
By default, registry keys and values created by Setup are not deleted at uninstall time. If you want the uninstaller to delete keys or values, you must include one of the uninsdelete* flags described below.

Inno Setup - Deny ACL for registry keys

I need my setup to create a registry key or value which has deny-type read policy.
I've tried that:
Root: HKLM64; Subkey: "Software\mySoftware\myKey"; ValueType: string; ValueName: "PASSWORD"; ValueData: "{code:GetUserEnteredPassword}"; Permissions: admins-full system-read;
Unfortunately, that way created value 'PASSWORD' is still readable for users.
Please let me know if there is any idea how to create deny permissions with Inno Setup.
It's not possible with Inno Setup. It does not support anything like users-deny-style permissions.
What you can do, is to execute the regini command or PowerShell script from [Run] section or Pascal Script:
How to change registry values or permissions from a command line or a script (regini)
Change Permissions on Registry key via Command line (regini and PowerShell)

Secure the installation of a software by prompting for a serial number

I am working on a project (Java project) and using Inno Setup 5 to create an installer. How can I secure the use of the install.exe and ask a serial number during the installation?
Thanks for the help.
Inno Setup has a built-in functionality prompting for a serial number on the optional "User Information" page and verifying the entered number.
set the UserInfoPage directive to yes;
implement the CheckSerial event function to make the Inno Setup prompt the user for the serial number and to verify it;
use the {userinfoserial} constant in the [Registry] section to save the entered and verified number to registry.
[Setup]
UserInfoPage=yes
[Registry]
Root: HKLM; Subkey: "Software\My Company"; ValueType: string; ValueName: "SerialNumber"; \
ValueData: "{userinfoserial}"
[Code]
function CheckSerial(Serial: String): Boolean;
begin
Result := (Serial = '123');
end;
For a more advanced implementation, see CustomPage for Serial Number in Inno Setup.
I works. I recommand to add in the InnoSetup script :
Flags: uninsdeletekey
When the program is uninstalled, delete the entire key.
[Registry]
Root: HKLM; Subkey: "Software\MySoft"; ValueType: string; ValueName: "AppInfo"; ValueData: "value" ; Flags: uninsdeletekey
I used this link to recover the key in my soft.
value = WinRegistry.readString (
WinRegistry.HKEY_LOCAL_MACHINE,
"SOFTWARE\\MySoft",
"AppInfo");

Write key to registry if Task has NOT been selected by user

With a Task defined as:
Name: "TaskAutoLogon"; Description: "{cm:TaskAutoLogon}"; Flags: unchecked
the user can choose whether to write a key to Registry like this:
Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon; ValueType: dword; ValueName: AutoAdminLogon; ValueData: 1; Tasks: TaskAutoLogon
My question is:
How can I tell Inno Setup to write that key to Registry only if the Task has NOT been selected/checked?
I practically want to invert the meaning of the Task.
I know it can be done with some code in the [code] section, but I hope there is a more native way of doing this.
Thanks in advance!
There's no need for script code here. The Tasks parameter supports not operator, so you can write Tasks: not TaskAutoLogon to process your entry when the task is not selected:
[Registry]
Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon; ValueType: dword; ValueName: AutoAdminLogon; ValueData: 1; Tasks: not TaskAutoLogon

Inno Setup - how can I make my program run when a user logs in to Windows?

I want to use Inno Setup (http://www.jrsoftware.org/isfaq.php) to build an installer for an application.
I want this application to start whenever a user logs in to their account on the Windows machine.
How can I tell Inno Setup to make the program start when a user logs in?
Put a shortcut in the startup folder of All Users profile. See the knowledge base article 'Create shortcuts in the Startup (or Autostart) group' which includes the below example:
[Setup]
PrivilegesRequired=admin
[Icons]
Name: "{commonstartup}\My Program"; Filename: "{app}\MyProg.exe"
If you want the program to run only when the user that installed the program logs in, then use {userstartup} instead of {commonstartup}. In that case admin privileges is not required.
Or if you decide to write to 'Run' key of registry (kb article):
[Registry]
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "MyProg"; ValueData: """{app}\MyProg.exe"""; Flags: uninsdeletevalue
If you use 'HKLM', again admin privileges is required.
Maybe it would be helpful for someone...
I encountered some problems under windows 8 when trying to build setup that would automatically put autorun registry key such as:
Root: "HKCU"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "NHMMNAS"; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletevalue
for running my 32-bit .NET application on every Windows startup.
It occured that for 32-bit application a little modification was needed which was replacing Root: "HKCU" with Root: "HKCU32" so the entry in setup script was:
Root: "HKCU32"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "NHMMNAS"; ValueData: "{app}\{#MyAppExeName}"; Flags: uninsdeletevalue
After adding the line and reinstalling, my application started on system startup with no problems.

Resources