Home All Groups Group Topic Archive Search About

File location with Windows Services ?

Author
11 Mar 2006 7:03 PM
Mike B
Is there a way to specify where support files are located for a Windows
Service?

I would like to have my service write and read it's files to/from a
different location than Windows\System32.

I would also like to have this location changed based on the where the user
requests that myservice.exe is placed.

Comments?

Author
13 Mar 2006 2:29 PM
Dmytro Lapshyn [MVP]
Hi Mike,

It really depends on how you read the files, but you can probably always use
Assembly.GetExecutingAssembly().Location to determine the path where
myservice.exe resides.

Show quote
"Mike B" <Mi***@discussions.microsoft.com> wrote in message
news:72A4E3D0-ADC3-45FC-8CBF-29A2A47F6017@microsoft.com...
> Is there a way to specify where support files are located for a Windows
> Service?
>
> I would like to have my service write and read it's files to/from a
> different location than Windows\System32.
>
> I would also like to have this location changed based on the where the
> user
> requests that myservice.exe is placed.
>
> Comments?
Author
14 Mar 2006 3:18 AM
Mike B
Thanks very much for your assistance.

I found a way to do this. After the service is installed I have my service
application read the ImagePath entry from the Registry. I then use this to
read or write any files that are required by the service.

I still have to look into the suggestion made by  Dmytro of using
"Assembly.GetExecutingAssembly().Location".  Dmytro, thanks very much for the
response.

Show quote
"Mike B" wrote:

> Is there a way to specify where support files are located for a Windows
> Service?
>
> I would like to have my service write and read it's files to/from a
> different location than Windows\System32.
>
> I would also like to have this location changed based on the where the user
> requests that myservice.exe is placed.
>
> Comments?

AddThis Social Bookmark Button