Community Discussions and Support
Polite way to ask Mercury/32 to exit?

[quote user="Rolf Lindby"]

If Mercury is running in program mode and my command daemon is loaded the daemon simply posts a WM_CLOSE to the window returned by get_variable(GV_FRAMEWINDOW).

/Rolf[/quote]

OK, Thanks.  That doesn't work if Mercury is "Hard to exit"; in that it just minimizes itself.  That's why my previous tests failed.  But that's OK.  I wouldn't use "Hard to exit" if Mercury were running on desktop 0.

[quote user="Rolf Lindby"]<p>If Mercury is running in program mode and my command daemon is loaded the daemon simply posts a WM_CLOSE to the window returned by get_variable(GV_FRAMEWINDOW).</p><p>/Rolf[/quote]</p><p>OK, Thanks.  That doesn't work if Mercury is "Hard to exit"; in that it just minimizes itself.  That's why my previous tests failed.  But that's OK.  I wouldn't use "Hard to exit" if Mercury were running on desktop 0. </p>

I switched to Win7/32.  Mercury works well started by a service (AUTOEXNT) but getting to desktop 0 to administer it is a pain.  I'd like my logon script to politely ask Mercury to exit and start it again (as me).  I don't mind writing the EXE; I just need to know how to ask Mercury to close.

 Or ...

 Does anyone know of a utility that will take me to/from desktop 0 on demand?

Thanks.

 - Vince

<p>I switched to Win7/32.  Mercury works well started by a service (AUTOEXNT) but getting to desktop 0 to administer it is a pain.  I'd like my logon script to politely ask Mercury to exit and start it again (as me).  I don't mind writing the EXE; I just need to know how to ask Mercury to close.</p><p> Or ...</p><p> Does anyone know of a utility that will take me to/from desktop 0 on demand? </p><p>Thanks.</p><p> - Vince </p>

As of Windows Vista Microsoft really doesn't want services or scheduled tasks to be interactive, so they have introduced session 0 isolation. Programs that need user interaction (for error handling, settings or whatever) are instead expected to provide some kind of interface that can be run as a regular program by the logged in user. Such an interface is being prepared for Mercury v5.

In the meantime it's possible to access some setting using the webtools package, but if the program runs in session 0 and you need the Mercury console window it gets tricky.

I haven't tested this, but I could think of two ways that might work:

1. Run Mercury in a virtual machine.

2. Use the workaround described here to have a remote session running as your normal user connecting back to your own computer.

If this doesn't work for you there are at least two ways to shut down Mercury remotely.

1. By sending an email:

MercExec Daemon
http://tstephenson.com/Mercury/MercExec150.zip 


This is a

daemon for Mercury/32 by David Harris to execute a command on the server by

sending an email.


How to

install


·Copy MercExec.dll

and

MercExec.xml to your Mercury/32 directory.


·Check and adjust all the settings in

the XML file


·Add an alias in the Aliases

to map the

email address to the daemon.


XML

settings file

All

settings need to be done my manually editing an XML file.

<MercExec Version="1.0">

<Options>

<FirstLinePassword Value="12345" />

</Options>

<Commands>

<Command Value="REBOOT" Exec="shutdown -r -f -t 0"

Hide="1" />

<Command Value="REBOOT SERVER2" Exec="shutdown -r -f

-t 0 -m \\server2" />

<Command Value="SCRIPT" Exec="bash –login -c

/home/user/script" Directory="c:\cygwin\bin" />

</Commands>

</MercExec>

2. By using a commandline tool:

http://community.pmail.com/forums/thread/30032.aspx

/Rolf 

 

&lt;p&gt;As of Windows Vista Microsoft really doesn&#039;t want services or scheduled tasks to be interactive, so they have&amp;nbsp;introduced&amp;nbsp;session 0 isolation. Programs that need user interaction (for error handling, settings or whatever) are instead expected to provide some kind of interface that can be run as a regular program by the logged in user. Such an interface is being prepared for Mercury v5.&lt;/p&gt;&lt;p&gt;In the meantime it&#039;s possible to access some setting using the webtools package, but if the program runs in session 0 and you need the Mercury console window it gets tricky.&lt;/p&gt;&lt;p&gt;I haven&#039;t tested this, but I could think of two ways that might work:&lt;/p&gt;&lt;p&gt;1. Run Mercury in a virtual machine.&lt;/p&gt;&lt;p&gt;2. Use the workaround described &lt;a href=&quot;http://wiki.imacros.net/How_to_Schedule_a_RemoteInteractive_Session&quot; target=&quot;_blank&quot; mce_href=&quot;http://wiki.imacros.net/How_to_Schedule_a_RemoteInteractive_Session&quot;&gt;here&lt;/a&gt; to have a remote session running as your normal user connecting back to your own computer.&lt;/p&gt;&lt;p&gt;If this doesn&#039;t work for you there are at least two ways to shut down Mercury remotely.&lt;/p&gt;&lt;p&gt;1. By sending an email:&lt;/p&gt;&lt;blockquote&gt;&lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;3&quot;&gt;&lt;span style=&quot;FONT-SIZE: 14pt&quot;&gt;MercExec Daemon&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font size=&quot;3&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#039;Lucida Sans Unicode&#039;; font-size: 16px; &quot;&gt;http://tstephenson.com/Mercury/MercExec150.zip&lt;/span&gt;&lt;/font&gt;&amp;nbsp;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;This is a daemon for Mercury/32 by David Harris to execute a command on the server by sending an email.&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;&lt;b&gt;How to install&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div style=&quot;TEXT-INDENT: 0mm; MARGIN: 0mm 0mm 0mm 13mm&quot; align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 9pt&quot;&gt;&middot;&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;Copy &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;MercExec.dll &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;and &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;MercExec.xml &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;to your Mercury/32 directory.&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div style=&quot;TEXT-INDENT: 0mm; MARGIN: 0mm 0mm 0mm 13mm&quot; align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 9pt&quot;&gt;&middot;Check and adjust all the settings in the XML file&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 9pt&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div style=&quot;TEXT-INDENT: 0mm; MARGIN: 0mm 0mm 0mm 13mm&quot; align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 9pt&quot;&gt;&middot;&lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;Add an alias in the &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;Aliases &lt;/span&gt;&lt;/font&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;to map the email address to the daemon.&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;&lt;b&gt;XML settings file&lt;/b&gt;&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt&quot;&gt;All settings need to be done my manually editing an XML file.&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;MercExec Version=&quot;1.0&quot;&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;Options&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;FirstLinePassword Value=&quot;12345&quot; /&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;/Options&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;Commands&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;Command Value=&quot;REBOOT&quot; Exec=&quot;shutdown -r -f -t 0&quot; Hide=&quot;1&quot; /&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;Command Value=&quot;REBOOT SERVER2&quot; Exec=&quot;shutdown -r -f -t 0 -m \\server2&quot; /&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;Command Value=&quot;SCRIPT&quot; Exec=&quot;bash &ndash;login -c /home/user/script&quot; Directory=&quot;c:\cygwin\bin&quot; /&amp;gt; &lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;div align=&quot;left&quot;&gt;&lt;i&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&lt;span style=&quot;FONT-SIZE: 8pt&quot;&gt;&amp;lt;/Commands&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;/i&gt;&lt;/div&gt; &lt;p&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#039;Courier New&#039;; font-size: 11px; &quot;&gt;&amp;lt;/MercExec&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;2. By using a commandline tool:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://community.pmail.com/forums/thread/30032.aspx&quot; mce_href=&quot;http://community.pmail.com/forums/thread/30032.aspx&quot;&gt;http://community.pmail.com/forums/thread/30032.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://community.pmail.com/forums/thread/30032.aspx&quot; mce_href=&quot;http://community.pmail.com/forums/thread/30032.aspx&quot;&gt;&lt;/a&gt;/Rolf&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

Thanks, Rolf.  If it takes a daemon, I'd rather write it myself (and would enjoy doing so).  I looked over the daemon docs pretty well and the daemon interface does not appear to offer a way for the daemon to ask Mercury/32  to exit.  So how would a daemon do that?  I tried a few things.  Mercury doesn't exit when the frame window gets WM_QUERYENDSESSION, WM_ENDSESSION, or WM_CLOSE (which makes me wonder what happens when the system shuts down with Mercury running).

 - Vince

&lt;p&gt;Thanks, Rolf.&amp;nbsp; If it takes a daemon, I&#039;d rather write it myself (and would enjoy doing so).&amp;nbsp; I looked over the daemon docs pretty well and the daemon interface does not appear to offer a way for the daemon to ask Mercury/32&amp;nbsp; to exit.&amp;nbsp; So how would a daemon do that?&amp;nbsp; I tried a few things.&amp;nbsp; Mercury doesn&#039;t exit when the frame window gets WM_QUERYENDSESSION, WM_ENDSESSION, or WM_CLOSE (which makes me wonder what happens when the system shuts down with Mercury running). &lt;/p&gt;&lt;p&gt;&amp;nbsp;- Vince &lt;/p&gt;

Session 0 isolation will stop programs running in session 0 from receiving Windows messages from other sessions, so there has to be a daemon involved. As the daemon is loaded by the Mercury process messages sent by it won't be blocked. But you will still need a way to communicate from other sessions to the daemon, of course.

/Rolf

&lt;p&gt;Session 0 isolation will stop programs running in session 0 from receiving Windows messages from other sessions, so there has to be a daemon involved. As the daemon is loaded by the Mercury process messages sent by it won&#039;t be blocked. But you will still need a way to communicate from other sessions to the daemon, of course.&lt;/p&gt;&lt;p&gt;/Rolf&lt;/p&gt;

[quote user="Rolf Lindby"]

Session 0 isolation will stop programs running in session 0 from receiving Windows messages from other sessions, so there has to be a daemon involved. As the daemon is loaded by the Mercury process messages sent by it won't be blocked. But you will still need a way to communicate from other sessions to the daemon, of course.[/quote]

I was testing with Mercury/32 running on my desktop; I watched it receive the messages (with Spy++) and it wouldn't shutdown.  How does your daemon get it to shutdown?

 - Vince

[quote user=&quot;Rolf Lindby&quot;]&lt;p&gt;Session 0 isolation will stop programs running in session 0 from receiving Windows messages from other sessions, so there has to be a daemon involved. As the daemon is loaded by the Mercury process messages sent by it won&#039;t be blocked. But you will still need a way to communicate from other sessions to the daemon, of course.[/quote]&lt;/p&gt;&lt;p&gt;I was testing with Mercury/32 running on my desktop; I watched it receive the messages (with Spy++) and it wouldn&#039;t shutdown.&amp;nbsp; How does your daemon get it to shutdown?&lt;/p&gt;&lt;p&gt;&amp;nbsp;- Vince &lt;/p&gt;

If Mercury is running in program mode and my command daemon is loaded the daemon simply posts a WM_CLOSE to the window returned by get_variable(GV_FRAMEWINDOW).

/Rolf 

&lt;p&gt;If Mercury is running in program mode and my command daemon is loaded the daemon simply posts a WM_CLOSE to the window returned by&amp;nbsp;get_variable(GV_FRAMEWINDOW).&lt;/p&gt;&lt;p&gt;/Rolf&amp;nbsp;&lt;/p&gt;
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft