views:

923

answers:

7

I'm having an amazing amount of trouble starting and stopping a service on my remote server from my msbuild script.

SC.EXE and the ServiceController MSBuild task don't provide switches to allow a username/password so they won't authenticate, so I'm using RemoteService.exe from www.intelliadmin.com

-Authenticating with \xx.xx.xx.xxx -Authentication complete -Stopping service -Error: Access Denied

The user account details I'm specifying are for a local admin on the server, so whats up?! I'm tearing my hair out!

A: 

If I understand your scenario correctly, it could help running the script with a domain account which is administrator on your remote machine (or better: has the right to start and stop the service).

John Smithers
A: 

OK here's a bit more background. I have an an XP machine in the office running the CI server. The build script connects a VPN to the datacentre, where I have a Server 2008 machine. Neither of them are on a domain.

mcintyre321
A: 

Quick followup question - can you use the "runas" command from an MSBuild script? If so, wouldn't you be able to simply impersonate another user with runas /user:dsfsdf /password:dfdf sc.exe ... (or similiar - I haven't researched the command-line options)?

HenningK
+1  A: 

Often, you can connect to the IPC$ "pseudo-share" on the machine to help establish the credentials before running commands like SC.EXE. Use a command like:

C:\> net use \\xx.xx.xx.xx\ipc$ * /user:username

The "*" tells it to prompt you for the password.

Brad Wilson
A: 

@HenningK - runas lets you run under a local identity. in this case I need to tell it to impersonate an identity on the server

@Brad - hmm. part of the build script actually does connect using NET USE already - i'll it with SC.EXE in the script (I've only tried it manually through cmd so far) to see if the session has rights. Of course, I don't want it to prompt for the password, as this is on the build server, but that's OK as NET USE has a password switch.

I'm wondering if perhaps there's a security setting I need to grant in server 2008 that prevents remote access for services by default as the RemoteService.exe program I tried appears to authenticate correctly. Anyone heard of anything like that?

mcintyre321
A: 

BUMP! Still can't get it to connect. I looked at the security log and it seems the remote request are authenticating as a user OK (in fact as a member of Administrators) but when they try to start and stop the service, an access denied message is sent.

mcintyre321
+1  A: 

I've disabled UAC and now it seems to work.

mcintyre321