views:

17

answers:

2

I created a Windows service and an installer for it. Now I want to run the windows service under account say na\test.\

I am specifieng it in Projectinstaller.

this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;  
this.serviceProcessInstaller1.Password = "pass123"
this.serviceProcessInstaller1.Username = "na\test";

I am installing the above in so many servers.

All the servers might not have the permissions to na\test.

If it doesn't have permissions the installation is getting stopped. Is there anyway that I can catch that exception and if the user doesnt have permissions, restart the installation with local user account automatically.

+3  A: 

Rather than hard coding the values of the user account, why not test to see if the user has permissions on that machine before trying to install. If they do install using na\test otherwise, install using a local account.

Ardman
As I told, it has to be installed in 100s of machines..cannot go and test for all the machines and find out permissions...
Ramyacurious
You can test this in code.
Ardman
http://www.csharphelp.com/2006/05/c-security-features/
Ardman
+1  A: 

If your installer is created using NSIS install packager you can test for appropriate permissions and act on that during the install process, more here:

http://nsis.sourceforge.net/Docs/Chapter4.html

( look for requestExecutionLevel )

bharling