Reputation: 847
I'm running following powershell script to change logon user account of a remote service and then start it.
$result = $remoteService.Change($null,$null,$null,$null,$null,$null,$logonAccount, $logonPassword,$null,$null,$null)
if ($result.ReturnValue -eq '0')
{
write-host "logon account changed"
$remoteService.StartService();
}
else
{
write-host "Error: $result.ReturnValue"
};
If my password contains only alphanumeric chars, I can see that service starts as shown in result below
logon account changed
ReturnValue : 0
However another account includes password with special characters like @, # and - , if I use this account my service start fails with error code 15.
logon account changed
ReturnValue : 15
Same is the result of I use sc command (example)
sc \\servername config servicename obj= domain\accountname password= w@e#dF-sxs32
sc \\servername start servicename
[SC] StartService FAILED 1069:
The service did not start due to a logon failure.
I can manually change the logon user of service and start it successfully from the Windows services.msc UI using the same account as mentioned above. So I thought issue could be with the password.
I have struggled a lot with this. can anyone please help. Thanks
Upvotes: 3
Views: 8453
Reputation: 1286
I checked, your sc command works very well.
sc \\mycomp config myservice obj= mycomp\User1 password= w@e#dF-sxs32
So, the issue is not in password with @#-_
It seems your domain\accountname user does not have rights or privileges to run any service on the servername server.
See MSDN about Add the Log on as a service Right to an Account https://technet.microsoft.com/en-us/library/cc794944(v=ws.10).aspx
Upvotes: 1