20

I'm writing a script that periodically checks that certain services are running on remote workstations. I'm having a devil of a time getting an "SC \workst1 query" command working from one test machine to another. Both machines are running XP pro SP3. Neither is part of a domain. Both are in the same workgroup, and the administrator accounts have the same passwords.

I keep getting the "[SC] OpenSCManager FAILED 5: Access is denied" message, from either workstation to the other. I have tried using elevated privileges on both. Windows firewall software is turned off. There are no messages are showing up in the Event security logs. When (as administrator) I try going to "Computer Management" -> "connect to another computer" and access the remote services I get "Error 5 Access is denied".

I can set up a filesystem share between the two machines successfully, and "net use \workst1\IPC$ /user:Administrator" completes successfully, but the SC query still fails. I'm using IP addresses and not hostnames in these commands, but that doesn't help. I don't know what else to try. Thanks for the help.

Ralph Garou
  • 201
  • 1
  • 2
  • 3
  • Related and possible answer: [SO: Remote OpenSCManager fails with access denied](http://stackoverflow.com/a/8472174/1608670) – Ivan Chau Apr 16 '16 at 09:52

5 Answers5

30

Try to run the commans as a Administrator

start-> (type cmd in search box), right click on cmd, Run as a administrator -> execute your command

Ramkrishna
  • 409
  • 4
  • 5
23

You must have administrative rights on the remote machine. Moreover you must access the drive before calling "sc". This can be achieved in command line using

net use \\remotemachine\admin$ <password> /user:<username>

admin$ is a hidden shared drive accessible to administrators that "sc" uses to control services.

Teriblus
  • 789
  • 6
  • 17
5

I was having the same issue today trying to check if a service is enabled remotely. I could solve the issue modifying the User Account Control for remote restrictions in windows:

To disable UAC remote restrictions, follow these steps:

  1. Click Start, click Run, type regedit, and then press ENTER.
  2. Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  3. If the LocalAccountTokenFilterPolicy registry entry does not exist, follow these steps:
    On the Edit menu, point to New, and then click DWORD Value. Type LocalAccountTokenFilterPolicy, and then press ENTER. Right-click LocalAccountTokenFilterPolicy, and then click Modify. In the Value data box, type 1, and then click OK.
  4. Exit Registry Editor.

More information about this solution in this site.

Greg K
  • 10,770
  • 10
  • 45
  • 62
afonte
  • 938
  • 9
  • 17
  • I added this Registry key and then was able to query the remote machine if I ran `sc` / `psservice` in an Administrator command prompt – Greg K Feb 16 '18 at 14:04
0

Your user should be remote, from Manage and Local users and groups

Eze
  • 1
0

The UAC issue is obvious you have to pull down the lever for UAC setting Also while installing the services you can use the following command

SC create SERVICENAME DisplayName= "DISPLAYNAME" binPath= "PATH OF EXE" start= disabled type= share

Shailesh Tiwari
  • 295
  • 4
  • 4