Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Escaping a password when calling "sc config"

Posted on 2009-02-16
4
Medium Priority
?
2,683 Views
Last Modified: 2013-12-03
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

0
Comment
Question by:Mass Dot Net
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:oBdA
ID: 23653057
Put the password in double quotes:

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

Open in new window

0
 
LVL 9

Author Comment

by:Mass Dot Net
ID: 23654708
I tried that, but it still has problems.  Tried using a caret (^) and backslash (\) as escape characters, as well, but to no avail.
0
 
LVL 86

Accepted Solution

by:
oBdA earned 2000 total points
ID: 23654769
Are you sure that it's the "$"  at the beginning? I've set the password for a service account to something starting with a "$", and could set the password (and start the service) without problems using sc.
Any one of these characters can cause problems in a batch script or from the command line: ^ % & ( ) < > |
You can try if the password works by simply adding an "echo" in front of sc; if the password is listed correctly in the output generated, it should work for setting it as well.
The account has "Logon as service" user right? This right will automatically be given if you change the account in the GUI, but not using sc.exe.
0
 
LVL 9

Author Comment

by:Mass Dot Net
ID: 23671617
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

0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question