在 Windows 服务中使用 PsExec [英] Using PsExec in a Windows Service

查看:36
本文介绍了在 Windows 服务中使用 PsExec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 C# 创建了一个 Windows 服务,它为我执行差异网络维护任务.其中一项任务是远程对机器进行碎片整理,对于我的一些旧机器,我发现唯一的方法是将 psexec 与 defrag.exe 结合使用.当我简单地运行我的 C# 代码时,代码工作正常,但是当我将它转换为 Windows 服务时,它可以使用 Win32_Volume 表进行碎片整理,但在尝试使用 PsExec 对 XP 机器进行碎片整理时似乎挂断了.

我想我的问题是,在 Windows 服务中使用 PsExec 是否存在任何已知错误?如果是这样,对我可以使用的其他方法有什么建议吗?

谢谢.

解决方案

psexec 在第一次以给定用户身份运行时发出软件许可协议对话框,因此如果服务以其他用户身份运行,这可能是您的问题.

您可以通过添加参数来抑制这一点

/accepteula

这可能是你的问题,但显然我不能确定!

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.

解决方案

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!

这篇关于在 Windows 服务中使用 PsExec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆