InnoSetup: Find out reason for restart - inno-setup

I have an Inno Setup script that installs my application and its accompanying files.
On some systems a restart is required, on some not.
I would like to find out the reason for the required restart.
How would I do this most intelligently?
Thank you very much.

For debugging purposes you can peek inside
HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
to see if there are any moves/renames/deletes queued for the next reboot.
(Sysinternals utility viewer)

Use /LOG when you run the install and then look at the log file that it generates (by default in %TEMP%). It should fairly clearly show in there which files were queued for replacement on restart, or which other reasons caused a restart request to be issued.
Usually restarts are triggered by overuse of restartreplace without using something like AppMutex to ensure that the application has been shut down properly before installing, or from subinstalls executed during [Run].

Related

Changing restart message on Inno Setup Prepare To Install page

I am building an installer in Inno Setup v6.2.1 with prerequisites, which include .NET, runtimes, and KB fixes (Windows 7 SP1). The goal is to do potentially several reboots depending on if the machine is missing KBs or .NET etc.
I am able to achieve what I want so far using PrepareToInstall and can change the text by returning the appropriate string. No problems... however I can't find a way of changing the.
Setup must restart your computer. After restarting your computer, run Setup again to complete the installation of xxxxx
Because I am creating a runonce entry, the installer will automatically run after reboot (which it does). The text "run Setup again" is not relevant in my situation and I want to change the text to say that the installer will continue once you restart.
I have tried to find where to change this text but with no success. I assume that PreparingMemo might be the candidate but no luck or not sure how to use it. Any help would be appreciated.
See Handling and customizing errors and messages in Inno Setup.
This particular message is defined by the PrepareToInstallNeedsRestart message.
You can change it in the [Messages] section:
[Messages]
PrepareToInstallNeedsRestart=Setup must restart your computer. After restarting your computer, the Setup will continue to complete the installation of [name].%n%nWould you like to restart now?
If you need to change the message text dynamically, assign WizardForm.PreparingLabel.Caption. E.g. from CurPageChanged(wpPreparing) event.

Inno Setup CloseApplications during Uninstall? [duplicate]

In Inno Setup, one can use CloseApplication to enable the Windows restart manager, and check for running instances. This, however, does not apply to the uninstallation. The setup removes all files that are not in use, and shows a message along the lines of "not all files could be removed, please remove them manually".
The only way to check for running instances that seems to work during uninstall runs, is to use AppMutex.
Is there a way to enable the restart manager during the uninstallation as well?
No, you cannot use restart manager in uninstaller. But you can code it yourself:
How do you close then restart explorer.exe in Inno Setup uninstall using the Restart Manager?
Simpler, but less elegant solution is killing the application in InitializeUninstall.
For that see my answer to Uninstall fails because program is running. How do I make Inno Setup check for running process prior to attempting delete?

systemd Force Service to Complete Before Proceeding in CentOS 7.1

I have a service that needs to complete before I can let Linux start up continue. I'd rather not have to specify each service and target in a Before= statement in my .service files. In SysVInit, I just specified the start number I wanted with chkconfig.
I have tried defining a foo.target and a foo.service and set it with require= and after= for network.target (I need networking) as well as before=multi-user.target. This doesn't seem to be working. I have set up the foo.target.wants directory to have a symlink to foo.service.
I have tried turning on debug in system.conf, to see what's wrong and had disastrous results.
Any help would be appreciated.
I finally got everything working the way I wanted. It's not pretty, but...
I changed the systemd default to a special target that wants what services are needed and runs my script at the end. At the end of my script, systemctl isolate multi-user is issued. I've verified that this works as desired.

Run a windows service with uiaccess flag

I have a program that I want to display a window above the start screen in Windows 8. The only way to do that (that I know of) requires I set the flag uiaccess=true in the manifest. But, in order for that to work, the user of the program needs to be an administrator. So, I tried this method to get a service I install with the program to launch the main program. This way the any user can run the program once installed.
The problem is the uiaccess flag. It seems that in order to launch a program as described in the article, but with uiaccess, the service itself needs to have the uiaccess flag enabled (or else CreateProcessAsUser fails). And whenever I try to install the service with the uiaccess flag, I get the error "this process requires elevation."
So, the main question is: Is there a way to install a service that has this flag enabled? I admit that I expect the answer to be "no". Since a service running in session 0 would normally have no reason to have this flag, since there's no ui component allowed. But, I'm hoping that I'm wrong and there is a way.
Thank you, let me know if I need to clear up anything.
Before CreateProcessAsUser and after DuplicateHandle use function SetTokenInformation with TokenUIAccess 1

I can't kill MyApp.vshost.exe

I've managed to get myself in a state where I've no instances of devenv running, but still a MyApp.vshost.exe in the background (no visible windows or consoles).
I've tried TaskManager, ProcessExplorer and command line (taskkill /F /IM MyApp.vshost.exe), none of them complain, the command line even says 'PID 5824 stopped', but it's still there.
I know I can reboot, but I'd rather get to the bottom of this.
It doesn't look like it's this issue (http://support.microsoft.com/kb/982551), because I can reboot no problem (just have in fact, so won't be able to provide any further diagnostics, sorry).
EDIT
This is how I got into this pickle:
I was able to kill my persistent vshost process by following these steps (VS2010):
open the properties of my executable project
in the "Debug" tab, uncheck "Enable the Visual Studio hosting process"
save the project file
That was it, the process stopped, and there was no need to restart Visual Studio.
It seems to be the normal behaviour for this task. When you kill it the task is restarted.
So i advice you to close Visual Studio, that closes the *.vshost.exe task.
I had the same problem while working on a project with .NET 2.0 as target framework.
Temporary changing the target framework to .NET 4.0 client did the job for me.
However, Iam unsure how this is (is it?) related to the file lock issue.
Maybe that's the same problem as described in https://stackoverflow.com/a/1582747/254041 (pending I/O processes):
The MSDN API ref says "TerminateProcess initiates termination and returns immediately. This stops execution of all threads within the process and requests cancellation of all pending I/O. The terminated process cannot exit until all pending I/O has been completed or canceled.". Which means so much as: your I/O can block this process (though I wonder how it can bring your process to 100%, I/O usually doesn't do that).

Resources