简体   繁体   English

是否不使用WMI,PsExec或TopShelf远程安装服务?

[英]Install service remotely without using WMI, PsExec or TopShelf?

I need to install / uninstall services on remote machines from C# code. 我需要从C#代码在远程计算机上安装/卸载服务。

I can't use WMI due to firewall issues. 由于防火墙问题,我无法使用WMI。 I prefer not to use PsExec to remotely call SC.exe or using SC.exe \\\\server create locally as those options requires text parsing of the output. 我不希望使用PsExec远程调用SC.exe或在本地使用SC.exe \\\\server create ,因为这些选项需要对输出进行文本解析。

TopShelf is not an option as well. TopShelf也不是一个选择。

For starting / stopping I used ServiceController class with Impersonation. 对于启动/停止,我将ServiceController类与Impersonation一起使用。

You can create a batch file for the installation/uninstallation procedure and register it to a scheduled task to run once the minute after you create it and enable it. 您可以为安装/卸载过程创建一个批处理文件,并将其注册到计划任务中,以在创建并启用它后每分钟运行一次。 Use this library to manage scheduled tasks remotely: 使用此库可以远程管理计划的任务:

http://taskscheduler.codeplex.com/ http://taskscheduler.codeplex.com/

Set a delay on your task to wait one minute, check the exit code, then delete the job. 将任务的延迟设置为等待一分钟,检查退出代码,然后删除作业。

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

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