Window SC Command

480 pts.
Tags:
DOS
DOS Batch
DOS program
Windows Server
Windows Server 2008
I am using Windows “sc” command line program to query the status of services of a particular software that is installed in Windows 2008 server environment.

Software/Hardware used:
Windows 2008, SQL server 2005

Answer Wiki

Thanks. We'll let you know when a new response is added.

It looks like not all of my inquiry got posted. Only the first part is showing. I will attempt to post it again. Here goes.

I am using Windows “sc” command line program to query the status of services of a particular software that is installed in Windows 2008 server environment.

The problem I am having is this; these service names have spaces which cause the system to return no result or it just hangs and I have to do a control C to break out of the command. I tried putting quotes around the name but still no result.

What I find strange is when I run the command locally, with the quotes around the name, it works find. Example when I type the below statement I received the below Result;

Statement: SC QUERY “Service Name With Spaces” | FIND “STATE” | FIND “STOPPED”
Result : STATE : 4 RUNNING

However the below 2 statement examples, which include the server name where I want to check these services, returns nothing.

SC \\ServerName QUERY “Service Name With Spaces” | FIND “STATE” | FIND “STOPPED”
SC \\ServerName QUERY “Service Name With Spaces” | FIND “STATE”

There are other services on that same server that do not have spaces and I have no problem when I do a query on those, only with the ones with spaces in the name.
Has anyone encountered this problem and is there a work around.

Thanks for any help you can give.

I would try using %20 instead of a space if quotes aren’t working. Alternativly you could just use a remote management connection to check if the service is OK. Go to services on your machine and right click where it says ‘Services (local)’ and connect to another computer. It’s not as quick as something like the sc command bumped into a script or batch file but it does work and gives a good GUI if anything is wrong.

(It could be 20%, can’t remember exactly. Google it)

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • jutpro
    Thanks ErroneousGiant for your response. The %20 is correct, however it did not work in my situation.
    480 pointsBadges:
    report
  • Pjb0222
    Try this for your problem systems and see if it returns the service name as there: sc \System query type= all state= all bufsize= 48000 There may be a deeper issue involved.
    3,310 pointsBadges:
    report
  • jutpro
    Thank you Pjb0222 for your input. After running the statement you gave me I saw the error of my ways. I realized that I have been entering the wrong server name. You see, we have 2 servers with similar names, one has a number in the name while the other does not. Well it so happened that I used the one without the number, which is the wrong one.. The statement is now working fine and all is well. Thanks to everyone for all there helps and efforts
    480 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following