Click to See Complete Forum and Search --> : Starting Windows Service fails: 'access denied'


Mikey
July 3rd, 2004, 09:26 AM
Hi, Gurus!

I have created a windows service in C#.

My problem:
I can install it with installutil.exe but when I try to start it, I get an 'Error 5: Access denied' messagebox!

Here some System-Info:

+ My OS is Windows 2000.
+ Net-Framework-Version is v1.1.4322.
+ I'm logged on as an administrator and have full access to the windows-installer-folder, so this cannot be the reason for the error.

TIA for Your help!

Mikey :confused:

Alexei Kubarev
July 3rd, 2004, 11:12 AM
hmmz... can you please post a code that you use to start that service? that might help...;)

Mikey
July 3rd, 2004, 11:28 AM
Hi Alexei,

Thanks for Your reply!

This error occurs even with the simplest form of a Windows Service which was generated by the "New Project"-Visual.Net-Wizard.

All I did "on my own" was adding an Installer-Class by clicking the "Add Installer"-link!


Thanks for further Help!

Mikey :confused:

Alexei Kubarev
July 3rd, 2004, 11:30 AM
hmmz... wait a second... so you are trying to intall by clicking from the link on your form?!

Mikey
July 3rd, 2004, 11:47 AM
no, no,

I have installed the service (with "LocalSystem-Account") with the installutil-tool. That works fine.

But when I try to start it, e.q. via "net start service1" I get that error "access denied"!

???


Mikey

still
:confused:

Alexei Kubarev
July 3rd, 2004, 11:50 AM
hmmz... if youve installed the services... how about checking what type of settings it has (Auto/Manual/Disabled)..

Maybe its simply disabled and you cant start it... that way you will always get that error...
why not use Process.Start("service1.exe")??

Wouldnt it be better?

Mikey
July 3rd, 2004, 12:08 PM
Thanks, Alexei,

but the service isn't disabled. The StartUp-type is set to 'Manual'.

In the Services Property-Dialog I can even change the StartUp-type for my service!
But I just cannot start it.

???

Mikey :confused:

Alexei Kubarev
July 3rd, 2004, 12:10 PM
hmmz... you say Mikey :confused: ... now its Alexei :confused:
I have NO idea what so ever about the reason of this problem...
Can you try setting in to Automatic and rebooting your PC? to see that the service really starts...

Mikey
July 3rd, 2004, 02:57 PM
You're right.

When I reopen the Service Property-Dialog the StartUp-type is set back to 'Manual'. So I can't change it also.

???

Alexei Kubarev
July 3rd, 2004, 03:09 PM
hmmz... weird weird... okej... lets see...
any code youve writen for that service or is it just a wizard-created service without any additions?

Mikey
July 3rd, 2004, 03:11 PM
it is just wizard created! no additions!

Alexei Kubarev
July 3rd, 2004, 04:33 PM
WAIT!!!!!!!!
I might just have the solution...
It said -- access denied, right? so why not try to clode EVERYTHING that might be using that service :)
Including VS.net and even rebooting your PC... just try... it might work :D

Mikey
July 3rd, 2004, 04:36 PM
Good idea!

I'll try it...

Alexei Kubarev
July 3rd, 2004, 04:36 PM
Good luck :D

Mikey
July 3rd, 2004, 04:53 PM
Hi, Alexei!

Noop... - Didn't work

I also copied it to my second computer. Same behavior...

I feel, I have to talk to my psychotherapist... :sick: :p


Alexei, have You checked Your e-mail?
I've sent You the code. Can You reproduce the error on Your machine?

???

still :confused:

Alexei Kubarev
July 3rd, 2004, 04:55 PM
I dint recieve anything :( how about you try sending to info@codexp.net
or
a_kubarev@hotmail.com
Might work :)

Mikey
July 3rd, 2004, 05:00 PM
I have sent it to a_kubarev@hotmail.com 30 minutes ago.

Isn't it the right address?

I will send it again to Your other address info@codexp.net.


Thanks again for help!!

Alexei Kubarev
July 3rd, 2004, 05:05 PM
both of them are right addresses actually... :S
hmmz... io never recieved it on hotmails email...

and i wish a bit more help that i really am :( im not really good with services.. so its quite hard for me to see whats wrong...
Just trying to be a Windows (works quite fine after 1 liter of wine actually) :D and see what really is wrong there... :)

I will take a look at your code and try to figure out whats wrong..

Mikey
July 3rd, 2004, 05:11 PM
A sip of wine?

That's a good idea! :D

Doesn't solve problems but makes them look smaller :D

Alexei Kubarev
July 3rd, 2004, 05:16 PM
After a liter you just stop noticing them :)
Actually im having a problem with even installing your service :S

I just cant find the freaking installutil... it simply doesnt exist on my PC :S

If you dont really mind i think i have to stop for today with C# and programming in general...

I have a date tomorrow and im kinda dizzy right now...

do NOT do this at home kids : Programming and drinking wine :D
The result will be Chernobyl or a new Sasser worm..

I might not even make sence right now.. but tomorrow i will take a look at your project and try to help...

Ich spreche kine deutch, aber:
"Auf Wiedersehen, Mikey" :wave:

Talk to you later :D tomorrow i think..

Mikey
July 3rd, 2004, 05:21 PM
"Danke und Schlafe gut" :p

Thanks for today and good night!

iposeai
July 12th, 2004, 12:15 PM
I was having the same problem and searching for solution I found your mails....in the end I solved on my own by changing from local system to administrator of the domain the account used in the property page of the service......can thi be of any help?

Today i'm also looking for a sample.vbs file that enable me to obtain the size of specific file trhou the network....I can easily do it with a very simple objFSO.GetFile command but it works only on local file or on mapped network drive, what I would like to do is use the network name: \\computer_name\c:\file_name......got nothing?

kevinphys
August 9th, 2004, 01:15 PM
Your solution works very well.

katos
September 16th, 2004, 09:58 AM
I had the same problem with starting a basic windows service I created in vb.net. This is what worked for me. The folder where the executable resided security was setup inproperly. When I checked the properties page for the folder and went to the security tab and clicked on everyone. Everyone only had list folders rights when I changed this to full control, I was able to run the service as a localsystem.

mshaw
October 4th, 2004, 11:52 PM
Add these lines to your projectinstaller class in the InitializeComponent method:

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;

this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;

This will allow your service to run under the local account.