We help IT Professionals succeed at work.

NT Service- Error 183

sreekumarvk
sreekumarvk asked
on
I have created an NT Service using CNTService class. This application is a console application. I was able to successfully install and uninstall the service. But when I tried to start the service, I got an Error

Error 183, Cannot Create a File when that file already exists.

Can any one help me out. I am using the project given in the article
"Creating a Simple Win32 Service in C++
Nigel Thompson
Microsoft Developer Network Technology Group"
in MSDN, as my starting point of developing the code and have modified the onInit and RUN member functions.

Also how can I debug an NT Service when it is running??

Comment
Watch Question

jkr
CERTIFIED EXPERT
Top Expert 2012

Commented:
Your problem is the NT security - the service runs under the 'LocalSystem' account, which does probably not have the rights to access this file. Additionally, you cannot debug the service because of that different account, as you aren't allowed to access this service from the debugger. The solution for the two problems: Set the service to run under the account you're logged on to the machine -  this can be done using the 'services' control panel applet.

Author

Commented:
Hi,
I did what you told me to do. I went to the control pannel applet and modified the log on as "This account" and gave my account name. and I gave my password. I have admin rights in this system, but still it is giving the same error.
Any way out??
Thanks
Sree

Author

Commented:
hi,
Can my service Create/Read/Write to a text file which is present in the same directory as the exe file of my NT Service. Is there any security issuses there?
Thanks for the help in advance.
Sreekumar
Something to note: Generally, when services run, they run with thier current directory set to \winnt\system32 (as that is the current directory of the spawning process generally), not the directory where the .exe resides.

It's the same as being on c:\ and running a command like d:\go.exe

if go.exe opens a file "x.txt" it will be opening c:\x.txt

Commented:
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since nobody had a satisfying answer for you.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
Per recommendation, points refunded and question closed
Netminder
CS Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.