Install Application EventLog with InnoSetup - inno-setup

I want to install/create my own event log at install time using Inno Setup.
After a little bit of searching I found the key that needs to be created for nt source ...
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\[Source]
And it has an EventMessageFile value to log the messages themselves, (I think).
But I want the event source to be created during setup, (and run elevated if need be).
How can this be done?
And if the correct way is indeed to use the registry, what EventMessageFile must I use?
NB: When the app is running it is not elevated so it cannot happen at run time.

Yes, indeed, you create a key like
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\MyLog
And set value EventMessageFile to point to a DLL file that contain description strings for your events.
[Registry]
Root: HKLM; \
Subkey: "SYSTEM\CurrentControlSet\Services\EventLog\Application\MyLog"; \
ValueType: string; ValueName: "EventMessageFile"; ValueData: "{app}\MyLog.dll"
See Message Files article.

Related

Inno Setup: Calling uninstaller while in setup - is that a proper way to rollback?

I've got a task to sort out a problem with our product installer and eventually came to a dead end with no ideas.
The installation process goes like:
Install files
Configure some services in [Run] section
Run our custom product configurator
If step 3 is successful (configurator returned good exit code) then start those services
else rollback installation
So the issue was something Shroedinger's - on SOME machines there were unexpected reboot after cancelling install in configurator, without any questions. Of course that annoyed users.
I couldn't figure out the criteria by which the machine decided to reboot, but I stumbled onto this thing:
In [Run] section
Filename: "stub.exe"; Flags: runhidden skipifdoesntexist; BeforeInstall: ConfigureService
Then in [Code], ConfigureService calls for InstallationAbort proc if configurator returned bad exit code.
Next, in InstallationAbort:
Exec(ExpandConstant('{uninstallexe}'), '/VERYSILENT /noinstancecheck', '', SW_HIDE,
ewWaitUntilTerminated, ErrorCode);
So the author calls for uninstaller WHILE IN THE INSTALLER.
Using logs I determined, that installation program doesn't end after uninstaller completes work! It's moving to the next step (installation finished)! After that I can see in log
Restart needed? Yes
Note: system never reboots if configurator is not cancelled, i.e installation finishes the right way.
So what I tried:
Adding /NORESTART to uninstaller Exec call. Doesn't help. I think that's because it's installer, who decides to make a restart.
Adding WizardForm.CancelButton.OnClick(WizardForm.CancelButton); and some other calls to exit setup after call to uninstaller. Doesn't help.
Overriding NeedRestart function to return false in case of cancellation
As I tried to understand, author calls uninstaller because of need to delete installed services (i.e. call them in UninstallRun with special parameters)
So, my main question: Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run]?
Is that a normal practice to call uninstaller from code called from [Run] section, to undo changes made in [Run]?
In general, it's not a common practice. One should not abort installation in Run section. Inno Setup is not designed to handle that.
But if you need to, there's no other way. The code you have is most probably based on this:
How to force Inno Setup setup to fail when Run command fails?
But that does not imply that the installer should require reboot. There's some conflict between the installer and uninstaller.

In Inno Setup, how to rollback a "verysilent" installation?

I have created an installer using Inno Setup. The installer uses a packaged-in DLL to check availability of a specific device on the target machine. If the device is found, the installation is allowed to finish, otherwise the installation is rolled-back (rollback is done using below lines in script):
if <DeviceNotFound> then
begin
CancelWithoutPrompt := true;
WizardForm.Close;
end;
I have checked that the above check and rollback logic works fine if the setup is run with /silent cmd line param. However, when I use /silent param, the setup displays the Installation progress wizard form.
Also, I found that if I run the above setup in /verysilent mode, then the "DeviceNotFound" check logic works fine but the rollback logic doesn't work and it seems as if rollback logic doesn't get executed at all. Instead of performing rollback, the installer successfully installs.
Now, I have a requirement to run the setup silently so that no window is displayed but it must install or rollback based on device check. Therefore, I have the below queries:
Can I rollback the installer when it is running in /verysilent mode? If so, please advise how it may be achieved. I can detect verysilent install mode as shown in question:
How to detect whether the setup runs in very silent mode?
Alternatively, can I Hide/Minimize the Installation progress window when it is running in /silent mode? If so, please advise how it may be achieved.
Please help me with my above queries.
Sorry to be so descriptive but I tried to explain my problem and queries!
EDIT
I am not doing the above mentioned check in InitializeSetup(). I am doing the check from a function invoked by AfterInstall directive from [Files] section. I have a limitation that I cannot do it from InitializeSetup() as the packaged-in DLL is not extracted till [Files] section completes. I also need to run the installer in Windows PE (Preinstallation Environment), hence I cannot use ExtractTemporaryFile() function to forcefully extract the DLL because the {tmp} path is not valid in that environment. That leaves me with only one option is to check after [Files] section is done. Please advise!
Your constraint on not using ExtractTemporaryFile does not make sense.
The Inno Setup installer always creates a temporary folder for the installation.
2015-07-31 09:02:07.458 Created temporary directory: C:\Users\martin\AppData\Local\Temp\is-1CN29.tmp
If it is not possible to create the folder, the installation fails.
The Inno Setup tries to create the temporary folder in these locations:
%TMP%
%TEMP%
%USERPROFILE%
Windows installation folder (C:\Windows)
At least the last path has to exist even in the "Windows PE".
So I do not think, there's anything preventing you from using the ExtractTemporaryFile function.

How to bypass/disable UAC in setup Installation

Folk,
I need to bypass UAC, through my Installer. Please note I am using InnoSetup/NSIS/Advanced Installer. I have tried all settings like SILENT / VERYSILENT but nothing has worked.
Help me out :)
Regards
Subh
You cannot bypass UAC, the user is in control, that is the whole point of UAC! If you want to do machine wide changes that require Administrator privileges there is no way around it.
The only way to avoid it is to do per-user installs into [local]appdata & HKCU (Like Chrome etc). To avoid legacy setup detection you should use PrivilegesRequired/RequestExecutionLevel and only ask for lower/user privileges...
Thanks guys :)
I guess I fave found one solution of it, like If I do the following before Installing my EXE for temporary then on post Installation I revert it. then, I hope my purpose get solved.
[Registry]
Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"; ValueType: dword; ValueName: "ConsentPromptBehaviorAdmin"; ValueData: "0x00000000"
If anybody like to discuss on this ,
Here I am at skype : subh.anand
Go to Settings, Recovery, Advanced Restart. Press Trobleshoot, More Options, and Command Prompt. Then type in ren Utilman.exe Utilman1.exe ren cmd.exe Utilman.exe. Then go to the login screen, click the dotted power button and you have an admin command prompt!

Inno Setup silent install UAC

I am trying to construct a silent install using Inno Setup. I am using the /SILENT and /VERYSILENT command parameters, and everything works fine, except for the UAC window popping up at the start.
How do I get around this issue?
I have found a few posts loosely mentioning about using SignTool, but other sources have said that this will simply change the UAC box blue with the publisher parameter filled.
Can anyone help here? The scenario is an installer which will be distributed over the internet to update existing software on a machine silently without any user interaction.
To run a setup elevated without the UAC prompt, you need to run it from something that is already elevated. It would defeat the entire point of UAC if programs could elevate without the user controlling access.
Signing the executable does just show the publisher.
The basic idea is to first install a service that runs under the Local System account, and this service will launch your update installers so that updates can bypass UAC, and don't force the end user to run as admin. If you don't want to develop one on your own, there are 3rd party solutions like this:
http://www.autoupdateplus.com/
When your users first install your application, an "updater service" gets installed, and all subsequent updates can be silent.
(We used to use AutoUpdate+, but later decided to roll our own which just downloads the full installer file of our appliation and runs it silently. This wasn't possible with AutoUpdate+, we had to create update packages with the changed files, which turned out to be too much hassle, with too much room for error.)
I have found one solution of it, like If I do the following before Installing my EXE for temporary then on post Installation I revert it. then, I hope my purpose get solved.
[Registry] Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"; ValueType: dword; ValueName: "ConsentPromptBehaviorAdmin"; ValueData: "0x00000000"
You can install it as User Software. Then you have no problems with UAC because it is no system wide software. ProgramData must be stored in User Folders and Registery Settings must be done under CurrentUser.
Not sure if you like to do that.
But anyway. You do not have to take care of UAC. Companies will have a deployment server with elevated rights so silent deployment will not force there a UAC message.
The UAC message is the normal behavier

Inno Setup: Set default value for desktop icon-check box to true

I am struggling with getting Inno Setup to set the check box to true whether a desktop icon should be created. The documentation has not been any helpful concerning this issue as well as Googlism and Stackoverflow.
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
My thought was a value like "checked" for "Flags" but the documentation told me, that Flags isn't responsible for this.
They are checked by default, remove the Flags: unchecked.
At startup Setup will look in the registry to see if the same application is already installed, and if so, it will use the task settings of the previous installation as the default settings presented to the user in the wizard.
To prevent that behavior use UsePreviousTasks=no.
Documented here.

Resources