简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM