Link to home
Start Free TrialLog in
Avatar of Member_2_3718378
Member_2_3718378

asked on

Escaping a password when calling "sc config"

One of our users has a password that begins with a dollar sign ($), and it's causing problems when using it to set the username/password a service should be run as.

Here's a (redacted) example.  When I run the "sc config" command, it correctly sets the service's username to "james@ultrabacon.com", but the password isn't set properly, so the service cannot be started.  If I use the Services GUI to enter the same password, though, I'm able to start the service.

Is there a way to escape the password string so that special characters are ignored?
sc config serviceName start= auto obj= james@ultrabacon.com password= $ser1nade

Open in new window

Avatar of oBdA
oBdA

Put the password in double quotes:

sc config serviceName start= auto obj= james@ultrabacon.com password= "$ser1nade"

Open in new window

Avatar of Member_2_3718378

ASKER

I tried that, but it still has problems.  Tried using a caret (^) and backslash (\) as escape characters, as well, but to no avail.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Looks like encapsulating the [obj] value in quotes and removing the quotes around the [password] value fixed it.  Still not sure exactly why this happened, but I'm happy it was solved.
sc config serviceName start= auto obj= "james@ultrabacon.com" password= $ser1nade

Open in new window