简体   繁体   English

在Windows服务中使用PsExec

[英]Using PsExec in a Windows Service

I have created a Windows Service using C# which performs variance network maintenance tasks for me. 我已经使用C#创建了Windows服务,该服务为我执行了差异网络维护任务。 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. 任务之一是远程清除计算机,对于我的一些旧机器,我发现唯一的方法是将psexec与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. 当我仅运行C#代码时,该代码就可以正常工作,但是当我将其隐藏到Windows Service中时,它可以使用Win32_Volume表进行清理,但是在尝试使用PsExec对XP计算机进行碎片整理时似乎挂断了。

I guess my questions is, are there any known errors with using PsExec within a Windows Service? 我想我的问题是,在Windows Service中使用PsExec是否存在任何已知的错误? If so are there any suggestions for a different method I can use? 如果是这样,对我可以使用的其他方法有什么建议吗?

Thank you. 谢谢。

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. psexec首次以给定用户身份运行时,会发出一个软件许可协议对话框,因此,如果该服务以其他用户身份运行,则可能是您的问题。

You can suppress this by adding the parameter 您可以通过添加参数来抑制这种情况

/accepteula

This could be your problem, though obviously I can't be sure! 这可能是您的问题,尽管显然我不确定!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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