开发者

windows service -> batch file: access denied to stop the service

开发者 https://www.devze.com 2023-03-20 01:26 出处:网络
my开发者_开发知识库 service downloads an update, writes batch file and executes it by system() call. batch file stops the service, updates it and starts it back. everything works fine when I\'m logged

my开发者_开发知识库 service downloads an update, writes batch file and executes it by system() call. batch file stops the service, updates it and starts it back. everything works fine when I'm logged in as administrator. under regular user I receive "access denied" to stop service.

I hoped batch file will be run under system account because is lauched by a service. But seems it isn't. Please explain why not. Any workaround?


You could diagnose the problem by using the runas command from a terminal:

runas /user:mymachine\serviceaccount batchfile.bat

and also the icacls command to query and set the permissions:

icacls batchfile.bat

and look for the RX permission

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号