Sachin Kainth
Sachin Kainth

Reputation: 46740

SC.exe causes Access Denied

I am calling the following commands from machine A to machine B.

<Exec Command="net.exe use \\B /delete" IgnoreExitCode="true"></Exec>
<Exec Command="net.exe use \\B /user:B\<username> <password>" IgnoreExitCode="true"></Exec>
<Exec Command="sc.exe \\B stop <service name>" IgnoreExitCode="true" />

The first two commands work fine, but the last one results in an Access Denied erorr.

Does anyone know what I am doing wrong?

Thanks,

Sachin

Upvotes: 0

Views: 7955

Answers (2)

Richard
Richard

Reputation: 108975

Does <username> have access to control the service on B?

Service entries have ACLs too, normally only administrators have control access, but this can be changed. This can include blocking local administrators from stopping a service.

Upvotes: 0

Strillo
Strillo

Reputation: 2972

Looks like the account under which you are running the script does not have the required privileges to stop services. See Services permissions

Upvotes: 1

Related Questions