I am using sc command to query status of a service running on computer PRODSRV from two computers. It works fine from one, but fails from another. What do I do wrong?

PRODSRV is Windows Server 2003. Computer from which sc works is also Windows Server 2003, the result of sc from it:

sc \\prodsrv query mssqlserver

SERVICE_NAME: mssqlserver
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Computer from which sc does not work is Windows Vista and the result is:

sc \\prodsrv query mssqlserver
[SC] OpenSCManager FAILED 5:

Access is denied.

Thank you!

3 Answers 3


Looks like your credential to access PRODSRV remotely doesn't have rights to query services.

Are the PRODSRV and Vista machines you're showing members of the same domain? How are you logged-on to each machine when you run this command?

It looks like a credential problem is all you're dealing with. Let us know re: the above and we'll work out how you need to be logged-on. You can probably get away with doing a "NET USE" to PRODSRV before you run the SC command and be home-free...

Edit: Before you run the SC, do the following:

NET USE \\PRODSRV\IPC$ /USER:<username you logon to PRODSRV with> <password you use on PRODSRV>

I'm suspecting that you're not using exactly the name username and password on the Vista machine and PRODSRV, but you are on PRODSRV and the other Windows 2003 box.

  • Ok. PRODSRV is running inside VirtualBox. Vista is a host to this virtualbox. There is no domain, just a workgroup. All machines belong to this workgroup. I am logged in under my user account on Vista, but this user account has Administrator credentials. On another win2003 machine from which sc works I am logged in as Administrator.
    – Anonymous
    Jun 4, 2009 at 18:22
  • No problem. You'll find that command useful if to connect to servers in other domains, etc. Once you've "mapped" an IPC connection you can map drives, and run most MS-RPC based administration programs (many of the server admin tools that come w/ Windows Server). It's quite handy to know how to do, and most people seem to have no idea. (Trying to get credentials established thru Explorer has always been spotty with me. Once you've got an IPC connection setup, you can use Explorer to browse the remote computer's filesystem fine.) To "disconnect", do a "NET USE \\PRODSRV\IPC$ /D". Jun 5, 2009 at 2:31

You can check the security event log to see what the PRODSRV thinks about your credentials from the Vista system. That might provide a hint about what's going on. You can access the security event log by running compmgmt.msc on the 2003 system, System Tools - Event Viewer - Security.

  • I don't think that the Security event log on the Vista clent is going to say anything helpful, but the Security event log on PRODSRV just might. Jun 4, 2009 at 11:26
  • You're right on that, this is what happens when I answer a question just before bed. I'll edit my answer appropriately, thanks for the heads up.
    – David Yu
    Jun 4, 2009 at 15:58
  • I will check security log when I get home. Thanks.
    – Anonymous
    Jun 4, 2009 at 18:23
  • there is nothing about it in security log (or any others)
    – Anonymous
    Jun 5, 2009 at 2:18

Depending on who you are running the query as, and where, you are going to get different results - largely based on if you are a member of the "Interactive" group.

I wrote a post about querying the status of a Windows service on my blog a while back, which I think has a solution (or at least will be helpful to other people). Look at the service with subinacl, and see the access control list.

You can then add permission to query for your specific user/group.

You must log in to answer this question.