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.

link|improve this question
looking now - I am not certain it was ever working before – Adam Butler Apr 7 '11 at 15:05
feedback

1 Answer

up vote 2 down vote accepted

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

%COMPUTERNAME%\MY_SERVUSER

as the username.

link|improve this answer
1  
.\MY_SERVUSER might also work. – William Jackson Apr 7 '11 at 14:59
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.