# Win32 Service Problem

**URL:** <https://rubytalk.org/t/win32-service-problem/46303>\
**Category:** ruby-talk\
**Created:** [6 May 2008 00:24 UTC](https://rubytalk.org/t/win32-service-problem/46303 "2008-05-06T00:24:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [6 May 2008 00:24 UTC](https://rubytalk.org/t/win32-service-problem/46303/1 "2008-05-06T00:24:19Z")

</div>

I'm having an issue with Win32 Service

I have a simple script that I want to run as a service however the service  
won't start (timeout issue). I've tried several things but nothing I do  
seems to make any difference at all.

Here is the code:

begin  
&nbsp;&nbsp;require 'rubygems'  
&nbsp;&nbsp;require 'win32/service'  
&nbsp;&nbsp;require 'chronic'

&nbsp;&nbsp;include Win32

&nbsp;&nbsp;class Daemon  
&nbsp;&nbsp;&nbsp;&nbsp;def service\_init  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test\_log = File.new("path\_to\_where\_it\_goes", "w")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test\_log.puts "got to init"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test\_log.close  
&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;def service\_main  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while running?  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if Time.now \< Chronic.parse('today 10:00pm')  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(Chronic.parse('today 10:00pm') - Time.now)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`shutdown /s /t:60`  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(Chronic.parse('tomorrow 10:00pm') - Time.now)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`shutdown /s /t:60`  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;end  
rescue Exception  
&nbsp;&nbsp;logfile = File.new("path\_to\_logfile", "w")  
&nbsp;&nbsp;logfile.puts $!  
&nbsp;&nbsp;logfile.close  
end

Daemon.mainloop

I get absolutely no feedback from the script it's self. In the even log it  
says the service didn't respond within 30 seconds. Oddly enough it decides  
this after a second or two. I've tried the script with different code in  
the service\_init method and without a service\_init method it doesn't seem to  
make any difference.

I realize this would be easier with a task but for reasons beyond my control  
the task scheduler is turned off on all classroom and lab computers.

> **···**
>
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)\
**Post date:** [6 May 2008 00:47 UTC](https://rubytalk.org/t/win32-service-problem/46303/2 "2008-05-06T00:47:28Z")

</div>

There's no shell associated with a service, so doing backticks or  
system commands in a service is a Bad Idea. Also, as of version 0.6.0  
STDIN, STDOUT and STDERR are redirected to NUL by default, so you'll  
have to reopen STDERR to a log file if you want to see the full output  
(what you saw there happened before they were redirected).

My recommendation is not to use backticks but to use WMI +  
Win32\_OperatingSystem via OLE. You can find details at:

> **[Win32\_OperatingSystem class - Win32 apps](https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-operatingsystem?redirectedfrom=MSDN)**
>
> Represents a Windows-based operating system installed on a computer.

Regards,

Dan

> **···**
>
> On May 5, 6:24 pm, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:
> 
> > I'm having an issue with Win32 Service
> > 
> > I have a simple script that I want to run as a service however the service  
> > won't start (timeout issue). I've tried several things but nothing I do  
> > seems to make any difference at all.
> > 
> > Here is the code:
> > 
> > begin  
> > &nbsp;&nbsp;require 'rubygems'  
> > &nbsp;&nbsp;require 'win32/service'  
> > &nbsp;&nbsp;require 'chronic'
> > 
> > &nbsp;&nbsp;include Win32
> > 
> > &nbsp;&nbsp;class Daemon  
> > &nbsp;&nbsp;&nbsp;&nbsp;def service\_init  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test\_log = File.new("path\_to\_where\_it\_goes", "w")  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test\_log.puts "got to init"  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test\_log.close  
> > &nbsp;&nbsp;&nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;def service\_main  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while running?  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if Time.now \< Chronic.parse('today 10:00pm')  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(Chronic.parse('today 10:00pm') - Time.now)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`shutdown /s /t:60`  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(Chronic.parse('tomorrow 10:00pm') - Time.now)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`shutdown /s /t:60`  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;end  
> > rescue Exception  
> > &nbsp;&nbsp;logfile = File.new("path\_to\_logfile", "w")  
> > &nbsp;&nbsp;logfile.puts $!  
> > &nbsp;&nbsp;logfile.close  
> > end
> > 
> > Daemon.mainloop
> > 
> > I get absolutely no feedback from the script it's self. In the even log it  
> > says the service didn't respond within 30 seconds. Oddly enough it decides  
> > this after a second or two. I've tried the script with different code in  
> > the service\_init method and without a service\_init method it doesn't seem to  
> > make any difference.
> > 
> > I realize this would be easier with a task but for reasons beyond my control  
> > the task scheduler is turned off on all classroom and lab computers.

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [6 May 2008 12:59 UTC](https://rubytalk.org/t/win32-service-problem/46303/3 "2008-05-06T12:59:39Z")

</div>

Thanks, I'll give it a shot.

> **···**
>
> On Mon, May 5, 2008 at 6:47 PM, Daniel Berger \<djberg96@gmail.com\> wrote:
> 
> > On May 5, 6:24 pm, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:  
> > \> I'm having an issue with Win32 Service  
> > \>  
> > \> I have a simple script that I want to run as a service however the  
> > service  
> > \> won't start (timeout issue). I've tried several things but nothing I do  
> > \> seems to make any difference at all.  
> > \>  
> > \> Here is the code:  
> > \>  
> > \> begin  
> > \> require 'rubygems'  
> > \> require 'win32/service'  
> > \> require 'chronic'  
> > \>  
> > \> include Win32  
> > \>  
> > \> class Daemon  
> > \> def service\_init  
> > \> test\_log = File.new("path\_to\_where\_it\_goes", "w")  
> > \> test\_log.puts "got to init"  
> > \> test\_log.close  
> > \> end  
> > \>  
> > \> def service\_main  
> > \> while running?  
> > \> if Time.now \< Chronic.parse('today 10:00pm')  
> > \> sleep(Chronic.parse('today 10:00pm') - Time.now)  
> > \> `shutdown /s /t:60`  
> > \> else  
> > \> sleep(Chronic.parse('tomorrow 10:00pm') - Time.now)  
> > \> `shutdown /s /t:60`  
> > \> end  
> > \> end  
> > \> end  
> > \> end  
> > \> rescue Exception  
> > \> logfile = File.new("path\_to\_logfile", "w")  
> > \> logfile.puts $!  
> > \> logfile.close  
> > \> end  
> > \>  
> > \> Daemon.mainloop  
> > \>  
> > \> I get absolutely no feedback from the script it's self. In the even log  
> > it  
> > \> says the service didn't respond within 30 seconds. Oddly enough it  
> > decides  
> > \> this after a second or two. I've tried the script with different code  
> > in  
> > \> the service\_init method and without a service\_init method it doesn't  
> > seem to  
> > \> make any difference.  
> > \>  
> > \> I realize this would be easier with a task but for reasons beyond my  
> > control  
> > \> the task scheduler is turned off on all classroom and lab computers.
> > 
> > There's no shell associated with a service, so doing backticks or  
> > system commands in a service is a Bad Idea. Also, as of version 0.6.0  
> > STDIN, STDOUT and STDERR are redirected to NUL by default, so you'll  
> > have to reopen STDERR to a log file if you want to see the full output  
> > (what you saw there happened before they were redirected).
> > 
> > My recommendation is not to use backticks but to use WMI +  
> > Win32\_OperatingSystem via OLE. You can find details at:
> > 
> > [Microsoft Learn: Build skills that open doors in your career](http://msdn.microsoft.com/en-us/library/aa394239(VS.85).aspx&lt;http://msdn.microsoft.com/en-us/library/aa394239%28VS.85%29.aspx&gt);
> > 
> > Regards,
> > 
> > Dan
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [6 May 2008 16:40 UTC](https://rubytalk.org/t/win32-service-problem/46303/4 "2008-05-06T16:40:19Z")

</div>

Okay now I'm getting undefined method mainloop for Daemon.

I'll try re-installing the gem but this seems a bit odd to me.

> **···**
>
> On Tue, May 6, 2008 at 6:59 AM, Glen Holcomb \<damnbigman@gmail.com\> wrote:
> 
> > Thanks, I'll give it a shot.
> > 
> > On Mon, May 5, 2008 at 6:47 PM, Daniel Berger \<djberg96@gmail.com\> wrote:
> > 
> > \>  
> > \>  
> > \> On May 5, 6:24 pm, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:  
> > \> \> I'm having an issue with Win32 Service  
> > \> \>  
> > \> \> I have a simple script that I want to run as a service however the  
> > \> service  
> > \> \> won't start (timeout issue). I've tried several things but nothing I  
> > do  
> > \> \> seems to make any difference at all.  
> > \> \>  
> > \> \> Here is the code:  
> > \> \>  
> > \> \> begin  
> > \> \> require 'rubygems'  
> > \> \> require 'win32/service'  
> > \> \> require 'chronic'  
> > \> \>  
> > \> \> include Win32  
> > \> \>  
> > \> \> class Daemon  
> > \> \> def service\_init  
> > \> \> test\_log = File.new("path\_to\_where\_it\_goes", "w")  
> > \> \> test\_log.puts "got to init"  
> > \> \> test\_log.close  
> > \> \> end  
> > \> \>  
> > \> \> def service\_main  
> > \> \> while running?  
> > \> \> if Time.now \< Chronic.parse('today 10:00pm')  
> > \> \> sleep(Chronic.parse('today 10:00pm') - Time.now)  
> > \> \> `shutdown /s /t:60`  
> > \> \> else  
> > \> \> sleep(Chronic.parse('tomorrow 10:00pm') - Time.now)  
> > \> \> `shutdown /s /t:60`  
> > \> \> end  
> > \> \> end  
> > \> \> end  
> > \> \> end  
> > \> \> rescue Exception  
> > \> \> logfile = File.new("path\_to\_logfile", "w")  
> > \> \> logfile.puts $!  
> > \> \> logfile.close  
> > \> \> end  
> > \> \>  
> > \> \> Daemon.mainloop  
> > \> \>  
> > \> \> I get absolutely no feedback from the script it's self. In the even  
> > log  
> > \> it  
> > \> \> says the service didn't respond within 30 seconds. Oddly enough it  
> > \> decides  
> > \> \> this after a second or two. I've tried the script with different code  
> > \> in  
> > \> \> the service\_init method and without a service\_init method it doesn't  
> > \> seem to  
> > \> \> make any difference.  
> > \> \>  
> > \> \> I realize this would be easier with a task but for reasons beyond my  
> > \> control  
> > \> \> the task scheduler is turned off on all classroom and lab computers.  
> > \>  
> > \> There's no shell associated with a service, so doing backticks or  
> > \> system commands in a service is a Bad Idea. Also, as of version 0.6.0  
> > \> STDIN, STDOUT and STDERR are redirected to NUL by default, so you'll  
> > \> have to reopen STDERR to a log file if you want to see the full output  
> > \> (what you saw there happened before they were redirected).  
> > \>  
> > \> My recommendation is not to use backticks but to use WMI +  
> > \> Win32\_OperatingSystem via OLE. You can find details at:  
> > \>  
> > \> [Microsoft Learn: Build skills that open doors in your career](http://msdn.microsoft.com/en-us/library/aa394239(VS.85).aspx&lt;http://msdn.microsoft.com/en-us/library/aa394239%28VS.85%29.aspx&gt);  
> > \<[Microsoft Learn: Build skills that open doors in your career](http://msdn.microsoft.com/en-us/library/aa394239%28VS.85%29.aspx&gt);  
> > \>  
> > \> Regards,  
> > \>  
> > \> Dan  
> > \>  
> > \>
> > 
> > --  
> > "Hey brother Christian with your high and mighty errand, Your actions  
> > speak  
> > so loud, I can't hear a word you're saying."
> > 
> > -Greg Graffin (Bad Religion)
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)\
**Post date:** [6 May 2008 17:34 UTC](https://rubytalk.org/t/win32-service-problem/46303/5 "2008-05-06T17:34:08Z")

</div>

You can fire up irb and check your version.

p Win32::Service::VERSION

You'll want 0.6.0 or later.

Regards,

Dan

> **···**
>
> On May 6, 10:40 am, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:
> 
> > Okay now I'm getting undefined method mainloop for Daemon.
> > 
> > I'll try re-installing the gem but this seems a bit odd to me.

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [6 May 2008 17:52 UTC](https://rubytalk.org/t/win32-service-problem/46303/6 "2008-05-06T17:52:09Z")

</div>

Well I'm running 0.6.1

I tried going back to 0.5.2 as that had worked for me in the past but no  
luck. I went back to 0.6.1 again and still the same error.

> **···**
>
> On Tue, May 6, 2008 at 11:34 AM, Daniel Berger \<djberg96@gmail.com\> wrote:
> 
> > On May 6, 10:40 am, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:  
> > \> Okay now I'm getting undefined method mainloop for Daemon.  
> > \>  
> > \> I'll try re-installing the gem but this seems a bit odd to me.
> > 
> > You can fire up irb and check your version.
> > 
> > p Win32::Service::VERSION
> > 
> > You'll want 0.6.0 or later.
> > 
> > Regards,
> > 
> > Dan
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [6 May 2008 19:25 UTC](https://rubytalk.org/t/win32-service-problem/46303/7 "2008-05-06T19:25:08Z")

</div>

I tried a clean install of Ruby and everything on a machine that was  
recently set up. I still get the same error so I'm pretty much out of  
ideas.

> **···**
>
> On Tue, May 6, 2008 at 11:52 AM, Glen Holcomb \<damnbigman@gmail.com\> wrote:
> 
> > Well I'm running 0.6.1
> > 
> > I tried going back to 0.5.2 as that had worked for me in the past but no  
> > luck. I went back to 0.6.1 again and still the same error.
> > 
> > On Tue, May 6, 2008 at 11:34 AM, Daniel Berger \<djberg96@gmail.com\> wrote:
> > 
> > \>  
> > \>  
> > \> On May 6, 10:40 am, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:  
> > \> \> Okay now I'm getting undefined method mainloop for Daemon.  
> > \> \>  
> > \> \> I'll try re-installing the gem but this seems a bit odd to me.  
> > \>  
> > \> You can fire up irb and check your version.  
> > \>  
> > \> p Win32::Service::VERSION  
> > \>  
> > \> You'll want 0.6.0 or later.  
> > \>  
> > \> Regards,  
> > \>  
> > \> Dan  
> > \>  
> > \>
> > 
> > --  
> > "Hey brother Christian with your high and mighty errand, Your actions  
> > speak  
> > so loud, I can't hear a word you're saying."
> > 
> > -Greg Graffin (Bad Religion)
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)\
**Post date:** [6 May 2008 19:45 UTC](https://rubytalk.org/t/win32-service-problem/46303/8 "2008-05-06T19:45:47Z")

</div>

Try Daemon.new.mainloop.

However, I'm still very confused by this. Try logging the version  
number to a file to make sure you're using the version you think  
you're using.

Regards,

Dan

> **···**
>
> On May 6, 1:25 pm, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:
> 
> > I tried a clean install of Ruby and everything on a machine that was  
> > recently set up. I still get the same error so I'm pretty much out of  
> > ideas.

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [6 May 2008 20:14 UTC](https://rubytalk.org/t/win32-service-problem/46303/9 "2008-05-06T20:14:36Z")

</div>

Nope, same error message.

Here is the current code:

require 'rubygems'  
require 'win32/service'  
require 'chronic'  
require 'win32ole'

include Win32

$stderr.reopen("C:\\Documents and  
Settings\\itstaff\\Desktop\\sandman\_error.log", "w")  
logfile = File.new("C:\\Documents and  
Settings\\itstaff\\Desktop\\sandman\_log.txt", "w")  
logfile.puts Win32::Service::VERSION  
logfile.close

class Daemon  
&nbsp;&nbsp;def service\_init  
&nbsp;&nbsp;&nbsp;&nbsp;mgmt =  
WIN32OLE.connect("winmgmts:{impersonationLevel=impersonate,(Shutdown)}//")  
&nbsp;&nbsp;&nbsp;&nbsp;wmi\_results = mgmt.ExecQuery("select \* from Win32\_OperatingSystem")  
&nbsp;&nbsp;end

&nbsp;&nbsp;def service\_main  
&nbsp;&nbsp;&nbsp;&nbsp;while running?  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if Time.now \< Chronic.parse('today 10:00pm')  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(Chronic.parse('today 10:00pm') - Time.now)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for target in wmi\_results  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target.Win32Shutdown(1)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(Chronic.parse('tomorrow 10:00pm') - Time.now)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for target in wmi\_results  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target.Win32Shutdown(1)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;end  
end

Daemon.new.mainloop

I wasn't sure about the scope with service\_init and service\_main was going  
to figure that out later, but it won't even get that far.

The version output from this file is 0.6.1

> **···**
>
> On Tue, May 6, 2008 at 1:45 PM, Daniel Berger \<djberg96@gmail.com\> wrote:
> 
> > On May 6, 1:25 pm, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:  
> > \> I tried a clean install of Ruby and everything on a machine that was  
> > \> recently set up. I still get the same error so I'm pretty much out of  
> > \> ideas.
> > 
> > Try Daemon.new.mainloop.
> > 
> > However, I'm still very confused by this. Try logging the version  
> > number to a file to make sure you're using the version you think  
> > you're using.
> > 
> > Regards,
> > 
> > Dan
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Daniel\_Berger2](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/daniel_berger2/32/2243_2.png) [@Daniel\_Berger2](https://rubytalk.org/u/Daniel_Berger2)\
**Post date:** [6 May 2008 20:34 UTC](https://rubytalk.org/t/win32-service-problem/46303/10 "2008-05-06T20:34:36Z")

</div>

\<snip\>

Add an explicit require 'win32/daemon' here and let me know if that  
helps.

Regards,

Dan

> **···**
>
> On May 6, 2:14 pm, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:
> 
> > Nope, same error message.
> > 
> > Here is the current code:
> > 
> > require 'rubygems'  
> > require 'win32/service'  
> > require 'chronic'  
> > require 'win32ole'

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [6 May 2008 20:41 UTC](https://rubytalk.org/t/win32-service-problem/46303/11 "2008-05-06T20:41:39Z")

</div>

That did the trick. Thanks Dan.

> **···**
>
> On Tue, May 6, 2008 at 2:34 PM, Daniel Berger \<djberg96@gmail.com\> wrote:
> 
> > On May 6, 2:14 pm, "Glen Holcomb" \<damnbig...@gmail.com\> wrote:  
> > \> Nope, same error message.  
> > \>  
> > \> Here is the current code:  
> > \>  
> > \> require 'rubygems'  
> > \> require 'win32/service'  
> > \> require 'chronic'  
> > \> require 'win32ole'
> > 
> > \<snip\>
> > 
> > Add an explicit require 'win32/daemon' here and let me know if that  
> > helps.
> > 
> > Regards,
> > 
> > Dan
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)
