Can Windows 7 service control command recognise username with localhost domain?

0

I have set up a new user called MY_SERVUSER on a Windows 7 via computer management on a computer that is not on a domain. I have a script that sets up our service to start as that user that used to work under previous windows but now doesn't.

The script calls something like:

sc config ConverterService start= auto obj= localhost\MY_SERVUSER password= password

Which gets this error:

The account name is invalid or does not exist, or the password is invalid for the account name specified.

But if I run it like this it works:

sc config ConverterService start= auto obj= computername\MY_SERVUSER password= password

The computer is not on a domain. My guess is that in Windows 7 there is some sort of domain even if we are not on a domain. Is this correct? Is there anything that can be done to allow my scripts to continue using localhost\username instead of computername\username?

If I need some other way to create the user that is fine but the same sc command must be able to run on multiple computers.

Adam Butler

Posted 2011-04-07T14:49:11.310

Reputation: 571

looking now - I am not certain it was ever working before – Adam Butler – 2011-04-07T15:05:10.883

Answers

3

Windows batch files have access to the current computer name as %COMPUTERNAME% so you can just use

%COMPUTERNAME%\MY_SERVUSER

as the username.

Majenko

Posted 2011-04-07T14:49:11.310

Reputation: 29 007

1.\MY_SERVUSER might also work. – William Jackson – 2011-04-07T14:59:10.740