WMI 启动服务参数

问题描述 投票:0回答:3

我目前正在使用 WMI 在我的 C# 代码中启动一个服务,我想设置其启动参数。

有办法做到这一点吗?到目前为止我找不到任何相关内容。

提前致谢。

托马斯。

service windows-services wmi
3个回答

0
投票

查看开源项目

服务+

包含 WMI 与 StartService 的完整用法

VB.Net 示例:

Dim objPath = "\\ComputerName\root\cimv2:Win32_Service.Name='ServiceName'"
Using objService As New ManagementObject(objPath)
   Dim outParams = objService.InvokeMethod("StartService", Nothing)
   rtnVal.WmiValue = CInt(outParams)
End Using

0
投票

历史:

嗨!

您需要使用 WMI 类 Win32_Process 连接到远程计算机。

然后您需要为远程计算机运行本地命令,例如“sc.exe start Spooler arg1” 如何使用 WMI 组件启动需要命令行参数的远程计算机进程

附注可能需要额外的 DACL 安全设置“sc.exe sdshow spooler”

© www.soinside.com 2019 - 2024. All rights reserved.