Using PsExec in a Windows Service

前提是你 提交于 2019-12-13 00:49:14

问题


I have created a Windows Service using C# which performs variance network maintenance tasks for me. One of the tasks is defraging machines remotely and for some of my older boxes I found the only way to do this was using psexec with defrag.exe. The code works fine when I simply run my C# code, however when I covert it into a Windows Service it does the defraging using the Win32_Volume table fine but it seems to get hung up when attempting to use PsExec to defrag the XP machines.

I guess my questions is, are there any known errors with using PsExec within a Windows Service? If so are there any suggestions for a different method I can use?

Thank you.


回答1:


psexec issues a software licence agreement dialog the first time it is run as a given user, so that could be your problem if the service is running as some other user.

You can suppress this by adding the parameter

/accepteula

This could be your problem, though obviously I can't be sure!



来源:https://stackoverflow.com/questions/14140826/using-psexec-in-a-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!