Changing working folder of services

  • Thread starter Thread starter Michael Groeger
  • Start date Start date
M

Michael Groeger

Hi everybody,

I rewrote a component of us so that it is now a service. Unfortunateley the
service cannot start, because the third party product relies on expects to
be started from a special working folder. My service itself is placed in
this folder but when starting a service the working folder is always the
system folder AFAIK. Is it possible to changed this either using MMC or by
code?

Regards,
Michael
 
Michael Groeger said:
Hi everybody,

I rewrote a component of us so that it is now a service. Unfortunateley the
service cannot start, because the third party product relies on expects to
be started from a special working folder. My service itself is placed in
this folder but when starting a service the working folder is always the
system folder AFAIK. Is it possible to changed this either using MMC or by
code?
....

Hi,

Try:

Environment.CurrentDirectory = (new
FileInfo(Assembly.GetExecutingAssembly().Location)).DirectoryName.ToString()
;

in service.OnStart(...)

Regards,
Goran
 
Thanks, that works!

Goran Sliskovic said:
...

Hi,

Try:

Environment.CurrentDirectory = (new
FileInfo(Assembly.GetExecutingAssembly().Location)).DirectoryName.ToString()
;

in service.OnStart(...)

Regards,
Goran
 
Back
Top