Hi Jano!
thnx for post!!
I use winXP, sp2.
Yeah service is registered. in “services” the status is “manual”
Yes im Admin an yes i can start other Services.
so here is my code:
require ‘rubygems’
require ‘win32/service’
include Win32
SERVICE_NAME = “cProjectsOutlookEventsListener3”
SERVICE_DISPLAYNAME = “cProjectsOutlookEventsListener3”
if ARGV[0] == “register”
#startet den service
svc = Service.new
svc.create_service{ |s|
s.service_name = SERVICE_NAME
s.display_name = SERVICE_DISPLAYNAME
s.binary_path_name = 'c:\ruby\bin ’ + File.expand_path($0)
s.dependencies = []
}
svc.close
puts "Service registriert: "+SERVICE_DISPLAYNAME
elsif ARGV[0] == “start”
Service.start(SERVICE_NAME)
puts “Service gestartet”
elsif ARGV[0] == “delete”
#stop service
if Service.status(SERVICE_NAME).current_state == “running”
Service.stop(SERVICE_NAME)
end
Service.delete(SERVICE_NAME)
puts "Service gelöscht: " + SERVICE_NAME
else
schreibe parameterinfo
puts “Use: ruby outlook_rubysvc.rb [option]”
puts " options:"
puts " register - Registriert und starte den Service"
puts " delete - Stoppt und löscht den Service"
exit
end
hier ist der eigentliche Service-code
class Daemon
def service_init
# Wartezeit bis der Service richtig initialisiert worden ist
sleep 10
end
def service_main
fileCount = 0
watchForFile = “C:\findme.txt”
while state == RUNNING
sleep 5
if File.exists? watchForFile
fileCount += 1
File.rename watchForFile, watchForFile + “.” + fileCount.to_s
end
end
end
d = Daemon.new
d.mainloop
end
thnx! Michael
Jano S. wrote:
On 7/11/07, Michael D. [email protected] wrote:
does anyone know how to fix this?
What system do you have? XP/W2k/vista?
Is the service already registered? (Can you see it in services?)
Can you start it with net start ?
Are you admin? Uberadmin in vista?
Can you start/stop other services?
Could you post the code you are trying to start?
Could you post the actual command (what did you do when you tried to
start the service)?
What do you do in your service?
You cannot use stdin, stdout, stderr; You don’t see mapped/subst-ed
disks, You might not have rights to some files - you are most probably
running under SYSTEM user.
(Now I see this looks like a confession recipe
J.