"SC stop spooler" Access denied

Sbrigham

Distinguished
Jun 29, 2011
4
0
18,510
Hello Tom's, long time lurker first time poster.

Systems Admin for my company, writing a batch file to restart the spooler service. "SC \\hostname stop spooler" works fine but when I run SC Stop spooler on the system itself it gives me the error:

C:\Users\mydomainname.mydomain\Desktop>sc stop spooler
[SC] OpenService FAILED 5:

Access is denied.


I'm logged in as an admin, like I said it works fine remotely just not when on the local system. and I need to do this on a lot of systems so changing the hostname in the .bat each time is not an option.

Any suggestions would be appreciated!!

(all win 7 pro, SP1, 2008 AD)
 

Sbrigham

Distinguished
Jun 29, 2011
4
0
18,510
Just a little more info



SERVICE_NAME: spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
 

Sbrigham

Distinguished
Jun 29, 2011
4
0
18,510
When run sc \\Myhostname stop spooler from a remote machine it works fine!



SERVICE_NAME: spooler
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 3 STOP_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

What is going on?!
 

Sbrigham

Distinguished
Jun 29, 2011
4
0
18,510
Sorry I was being an idiot got the answer from technet

"You need to make sure you're running the command prompt as Administrator. Type cmd in the start menu, then right-click it and hit "Run as Administrator" -- otherwise it uses your standard user token, for security purposes."

All day I was writing batch files for remote machines and I forgot about this.
 

harikumarcse23

Honorable
Jul 30, 2012
1
0
10,510



Thanks Sbrigham, your information helped us at ontime.