views:

127

answers:

1

I have recently switched to Windows 7 as my development machine. One of the components of the software that I work on is a Windows service. One of the tricks I use to debug the service is to make the service registry values point to my debug build of the service. I then start the service and attach to the process using VS.NET.

However, when I try to do this on Windows 7 and try to start the 'debug' version of the service I get an error message telling me that 'access is denied'. I thought there must be something wrong with my debug build of the service. But to troubleshoot the problem I tried creating a folder under 'Program Files' named 'DebugService', copying the contents of the debug build folder to this folder and pointing the service at this location. I was then able to start the service without error.

Has anybody come across this restriction in Windows 7? Having to copy the build output to a folder in 'Program Files' is inconvenient and my service is also experiencing permissions problems opening certain files that are located in this 'Program Files' folder (the installed version of the service has no such problems).

Is there some something I can do to Windows 7 to tell it that it's okay to start a service located in a folder that is not under 'Program Files'?

+2  A: 

Heh, I don't think there's anything special about Program Files... But there very likely is something special about your build location: it belongs to you, and not to the Users group. Assuming you're not running the service as yourself (or SYSTEM), that puts it in the uncomfortable position of trying to run a program that can't access its own code!

I just set up a separate directory tree off of root, accessible by the Users group, and build my stuff there. But you could certainly assign the necessary permissions to whatever directory you're already using.

Shog9
You're right. The difference with Windows 7 is that my code folders don't grant any permissions to the 'Users' groups. Once I granted permissions to the 'Users' group the service started up just fine. Thanks a lot.
jmatthias
The funny thing is that Windows 7 is the first OS where I haven't just created a folder off the root as you suggest. I thought I was being a good OS citizen by putting my code in the my documents folder.
jmatthias
Heh, well... I use my user directory for things that truly are personal, but development work tends to cross the line too often to be convenient. FWIW, I believe XP actually ran services under the SYSTEM account by default, thus giving them access to the entire filesystem - you can probably imagine why this was changed in Vista and Win7.
Shog9