<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Run Windows Service as a console program</title>
	<atom:link href="http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/feed/" rel="self" type="application/rss+xml" />
	<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/</link>
	<description></description>
	<pubDate>Mon, 12 May 2008 22:25:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: bryanbcook</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-20410</link>
		<dc:creator>bryanbcook</dc:creator>
		<pubDate>Tue, 29 Apr 2008 05:20:38 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-20410</guid>
		<description>Just to follow up, here's how I managed to get multiple services up and running in a single process:

http://stupiddumbguy.blogspot.com/2008/04/running-multiple-net-services-within.html</description>
		<content:encoded><![CDATA[<p>Just to follow up, here&#8217;s how I managed to get multiple services up and running in a single process:</p>
<p><a href="http://stupiddumbguy.blogspot.com/2008/04/running-multiple-net-services-within.html" rel="nofollow">http://stupiddumbguy.blogspot.com/2008/04/running-multiple-net-services-within.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bryanbcook</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-20372</link>
		<dc:creator>bryanbcook</dc:creator>
		<pubDate>Sat, 26 Apr 2008 01:23:33 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-20372</guid>
		<description>Gene/Jerry, I've also seen this problem.  I'm actively researching it.

http://stupiddumbguy.blogspot.com</description>
		<content:encoded><![CDATA[<p>Gene/Jerry, I&#8217;ve also seen this problem.  I&#8217;m actively researching it.</p>
<p><a href="http://stupiddumbguy.blogspot.com" rel="nofollow">http://stupiddumbguy.blogspot.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerry</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-14360</link>
		<dc:creator>Jerry</dc:creator>
		<pubDate>Tue, 04 Mar 2008 14:36:44 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-14360</guid>
		<description>Gene, I have the same problem.  Two services, both are instantiated, but only the first has its OnStart() called.  Did you ever resolve this issue?

Thanks,
Jerry</description>
		<content:encoded><![CDATA[<p>Gene, I have the same problem.  Two services, both are instantiated, but only the first has its OnStart() called.  Did you ever resolve this issue?</p>
<p>Thanks,<br />
Jerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: einar</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-12428</link>
		<dc:creator>einar</dc:creator>
		<pubDate>Wed, 13 Feb 2008 21:26:28 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-12428</guid>
		<description>Cool :)</description>
		<content:encoded><![CDATA[<p>Cool <img src='http://tech.einaregilsson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-12388</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 13 Feb 2008 11:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-12388</guid>
		<description>in order to provide standard behavior for closing a console app (ctrl+c) the following code would be a bit cooler:

[code]
static void Main(string[] args)
        {
            DemoService service = new DemoService ();

            if (Environment.UserInteractive)
            {
                service.OnStart(args);
                Console.CancelKeyPress += new ConsoleCancelEventHandler(
                    delegate(object sender, ConsoleCancelEventArgs e)
                    {
                        service.OnStop();
                    });

                /*
                Console.WriteLine("Press any key to stop program");
                Console.Read();
                service.OnStop();
                */
            }
            else
            {
                ServiceBase.Run(service);
            }
        }
[/code]</description>
		<content:encoded><![CDATA[<p>in order to provide standard behavior for closing a console app (ctrl+c) the following code would be a bit cooler:</p>
<p>[code]<br />
static void Main(string[] args)<br />
        {<br />
            DemoService service = new DemoService ();</p>
<p>            if (Environment.UserInteractive)<br />
            {<br />
                service.OnStart(args);<br />
                Console.CancelKeyPress += new ConsoleCancelEventHandler(<br />
                    delegate(object sender, ConsoleCancelEventArgs e)<br />
                    {<br />
                        service.OnStop();<br />
                    });</p>
<p>                /*<br />
                Console.WriteLine(&#8221;Press any key to stop program&#8221;);<br />
                Console.Read();<br />
                service.OnStop();<br />
                */<br />
            }<br />
            else<br />
            {<br />
                ServiceBase.Run(service);<br />
            }<br />
        }<br />
[/code]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: einar</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-11800</link>
		<dc:creator>einar</dc:creator>
		<pubDate>Thu, 07 Feb 2008 06:38:57 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-11800</guid>
		<description>I don't know. If you call the ServiceBase.Run method you're running them as services, not as console programs, and I would think that the ServiceBase should call OnStart in all of them. Maybe there is something in the documentation for ServiceBase?</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know. If you call the ServiceBase.Run method you&#8217;re running them as services, not as console programs, and I would think that the ServiceBase should call OnStart in all of them. Maybe there is something in the documentation for ServiceBase?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gene</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-11744</link>
		<dc:creator>Gene</dc:creator>
		<pubDate>Wed, 06 Feb 2008 18:48:13 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-11744</guid>
		<description>I used 2 service objects in my process using the following code:
  
ServiceBase[] ServicesToRun = new ServiceBase[] { new Service1(), new Service2() };



ServiceBase.Run(ServicesToRun);

I added trace statements to the Service1 and Service2 constructors and also to the OnStart and OnStop methods for bothe services.  What is strange is the although both constructors are called.  Only the first OnStart() method (that of Service1 is called and not Service2.OnStart.  Any idea why?</description>
		<content:encoded><![CDATA[<p>I used 2 service objects in my process using the following code:</p>
<p>ServiceBase[] ServicesToRun = new ServiceBase[] { new Service1(), new Service2() };</p>
<p>ServiceBase.Run(ServicesToRun);</p>
<p>I added trace statements to the Service1 and Service2 constructors and also to the OnStart and OnStop methods for bothe services.  What is strange is the although both constructors are called.  Only the first OnStart() method (that of Service1 is called and not Service2.OnStart.  Any idea why?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandy</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-10986</link>
		<dc:creator>Sandy</dc:creator>
		<pubDate>Wed, 30 Jan 2008 06:27:48 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-10986</guid>
		<description>Thanks einar for your valuable reply.</description>
		<content:encoded><![CDATA[<p>Thanks einar for your valuable reply.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: einar</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-10904</link>
		<dc:creator>einar</dc:creator>
		<pubDate>Tue, 29 Jan 2008 13:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-10904</guid>
		<description>You could make the service run as that user, this can be configured in the service properties. However, if you want the service to run as "system" and then start another process as another user, then you'll have to do some more complicated stuff, something like: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecurityPrincipalWindowsIdentityClassImpersonateTopic.asp</description>
		<content:encoded><![CDATA[<p>You could make the service run as that user, this can be configured in the service properties. However, if you want the service to run as &#8220;system&#8221; and then start another process as another user, then you&#8217;ll have to do some more complicated stuff, something like: <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecurityPrincipalWindowsIdentityClassImpersonateTopic.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecurityPrincipalWindowsIdentityClassImpersonateTopic.asp</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandy</title>
		<link>http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-10898</link>
		<dc:creator>Sandy</dc:creator>
		<pubDate>Tue, 29 Jan 2008 11:56:12 +0000</pubDate>
		<guid isPermaLink="false">http://tech.einaregilsson.com/2007/08/15/run-windows-service-as-a-console-program/#comment-10898</guid>
		<description>Nice!.. I have one difficulty....
I have written one service and executing another program from the service...
But now my problem is that I want to execute the program with local user 
privilege and not as a "system"... Is it possible to archive this...

Thanks in advance..

Sandy</description>
		<content:encoded><![CDATA[<p>Nice!.. I have one difficulty&#8230;.<br />
I have written one service and executing another program from the service&#8230;<br />
But now my problem is that I want to execute the program with local user<br />
privilege and not as a &#8220;system&#8221;&#8230; Is it possible to archive this&#8230;</p>
<p>Thanks in advance..</p>
<p>Sandy</p>
]]></content:encoded>
	</item>
</channel>
</rss>
