Can use RestartManager to avoid reboot? No (2: Session Mismatch)

274 views
Skip to first unread message

Bill Stewart

unread,
Jan 22, 2020, 4:18:29 PM1/22/20
to innosetup
I am building a setup program using Inno Setup 6.0.3 on Windows 10 (x64) version 1909.

It's a Cygwin application that uses cygrunsrv.exe to run a Windows service. I am using these settings in the [Setup] section:

CloseApplications=yes
CloseApplicationsFilter=*.chm,*.dll,*.exe,*.chm,*.pdf,*.ps1
RestartApplications=yes

When the service is running and I try to upgrade, this is what I see in the log file:

RestartManager found an application using one of our files: <executable file name>
RestartManager found an application using one of our files: <name of service>
Can use RestartManager to avoid reboot? No (2: Session Mismatch)

I tried rebooting my computer and trying again, but I still see the same error.

The service runs as LocalSystem (the SYSTEM account).

Any ideas on how I can fix this condition?

Thanks!

Bill

Martijn Laan

unread,
Jan 23, 2020, 5:45:09 AM1/23/20
to inno...@googlegroups.com
Hi,


Greetings,
Martijn

Op 22 jan. 2020 om 22:18 heeft Bill Stewart <bste...@iname.com> het volgende geschreven:


--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/0d97a003-b020-4e42-89b8-55511b25bd02%40googlegroups.com.

Bill Stewart

unread,
Jan 23, 2020, 10:08:47 AM1/23/20
to innosetup
On Thursday, January 23, 2020 at 3:45:09 AM UTC-7, Martijn Laan wrote:


Correct - I have read that.

The problem is, for some reason, the Restart Manager is returning error 2 (RmRebootReasonSessionMismatch) when the service is running (started using cygrunsrv).

If I stop the service and run another executable from the application directory (and leave it running), I get the "close applications" dialog without an issue.

If I start the service, the Restart Manager detection fails (RmRebootReasonSessionMismatch) and IS proceeds trying to install and overwrite files.

My question is: What is it about the cygrunsrv process that is causing Restart Manager to fail in this way?

Thanks

Bill

Martijn Laan

unread,
Jan 23, 2020, 11:29:45 AM1/23/20
to inno...@googlegroups.com
Restart Manager is a black box and doesn't provide any other information than this error code. You could try asking on some Microsoft forum since it's not really an Inno Setup question.

Greetings,
Martijn

Op 23 jan. 2020 om 16:08 heeft Bill Stewart <bste...@iname.com> het volgende geschreven:


--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.

Bill Stewart

unread,
Jan 23, 2020, 11:56:26 AM1/23/20
to innosetup
On Thursday, January 23, 2020 at 9:29:45 AM UTC-7, Martijn Laan wrote:

Restart Manager is a black box and doesn't provide any other information than this error code. You could try asking on some Microsoft forum since it's not really an Inno Setup question.

It seems that Restart Manager consistently fails with error 2 (RmRebootReasonSessionMismatch) for services started with cygrunsrv.

Reproduced on Windows 10 and 8.1/Windows Server 2008 R2.

Other processes work fine; it seems the services started by cygrunsrv cause this.

It appears there's nothing to do from the IS side.

Bill

Bill Stewart

unread,
Jan 24, 2020, 12:50:29 PM1/24/20
to innosetup
On Thursday, January 23, 2020 at 9:56:26 AM UTC-7, Bill Stewart wrote:

It appears there's nothing to do from the IS side.

But now that I think about it, RebootReasonSessionMismatch (2, "One or more processes are running in another Terminal Services session") isn't necessarily a "hard fail" condition, particularly when we're talking about a service.

It seems like CloseApplications=force should proceed with stopping apps/services, even when RmGetList returns RebootReasonSessionMismatch (2) in the lpdwRebootReasons output parameter?

Bill

Martijn Laan

unread,
Jan 25, 2020, 1:10:22 AM1/25/20
to inno...@googlegroups.com
Hi,

Op 24-1-2020 om 18:50 schreef Bill Stewart:
It seems like CloseApplications=force should proceed with stopping apps/services, even when RmGetList returns RebootReasonSessionMismatch (2) in the lpdwRebootReasons output parameter?


That's what it does already (regardless of the use of 'force'). The return value of RmGetList only has cosmetic effects.

Greetings,
Martijn

Bill Stewart

unread,
Jan 27, 2020, 10:15:48 AM1/27/20
to innosetup
On Friday, January 24, 2020 at 11:10:22 PM UTC-7, Martijn Laan wrote:

It seems like CloseApplications=force should proceed with stopping apps/services, even when RmGetList returns RebootReasonSessionMismatch (2) in the lpdwRebootReasons output parameter?

That's what it does already (regardless of the use of 'force'). The return value of RmGetList only has cosmetic effects.

Thanks Martijn.

When the service is running, the Restart Manager fails (with log entry noted previously). I thought that RmRebootReasonSessionMismatch output value was preventing Restart Manager from working. If I understand, you are saying this is not correct?

Please see here:


I am trying to understand why Restart Manager from IS works only when the service is stopped. If service is running, it does not work.

Thanks

Bill

Bill Stewart

unread,
Jan 27, 2020, 3:20:41 PM1/27/20
to innosetup
On Monday, January 27, 2020 at 8:15:48 AM UTC-7, Bill Stewart wrote:

I am trying to understand why Restart Manager from IS works only when the service is stopped. If service is running, it does not work.

The RestartManager PowerShell module (https://github.com/heaths/RestartManager) gives some interesting clues. Here are the commands I run:

----------
Set-Location <path to Cygwin root directory>
Start-RestartManagerSession
Get-ChildItem . -File -Include *.exe,*.dll -Recurse | RegisterRestartManagerResource
Get-RestartManagerProcess
Stop-RestartManagerProcess
----------

This produces the following output:

----------
Id                : <process ID>
StartTime         : <process start time>
Description       : <executable started by cygrunsrv>
ServiceName       :
ApplicationType   : Console
ApplicationStatus : Running
IsRestartable     : False
RebootReason      : SessionMismatch

Id                : <cygrunsrv process id>
StartTime         : <cygrunsrv process start time>
Description       : <description of service>
ServiceName       : <service name>
ApplicationType   : Service
ApplicationStatus : Running
IsRestartable     : True
RebootReason      : SessionMismatch

----------

The cause of the problem, of course, is that the bRestartable member of RM_PROCESS_INFO structure is 'true' for the cygrunsrv.exe program but 'false' for the executable it runs as a service.

I can work around this by doing something like this:

----------
CloseApplications=yes
CloseApplicationsFilter=*.chm,*.pdf
RestartApplications=yes
----------

And then this, in [Code]:

----------
[Code]
Procedure RegisterExtraCloseApplicationsResources();
  Begin
  RegisterExtraCloseApplicationsResource(False, ExpandConstant('{app}\bin\cygrunsrv.exe'));
  ...
  End;
----------

(Making sure to omit the .exe file that cygrunsrv.exe spawns)

However this isn't perfect, because if excluded executable is started independently of cygrunsrv.exe, it will not be detected by Restart Manager.

Any ideas on other workarounds, or why the Restart Manager behaves in this way?

Thanks!

Bill

Bill Stewart

unread,
Feb 5, 2020, 2:34:16 PM2/5/20
to innosetup
On Monday, January 27, 2020 at 1:20:41 PM UTC-7, Bill Stewart wrote:

Any ideas on other workarounds, or why the Restart Manager behaves in this way?

I don't know the answer, but I ended up working around the problem by writing some custom WMI code that detects running Cygwin services and processes.

If any Cygwin services are running, it stops them (using 'net stop' command) and remembers which services it stopped.

If any Cygwin processes are still running, it stops them (using 'taskkill' command).

After installation, it starts any services it stopped (using 'net start' command).

If anyone is interested, the code is here:


Bill
Reply all
Reply to author
Forward
0 new messages