gpt4 book ai didi

c# - 在应用程序启动时禁用 Windows 服务

转载 作者:可可西里 更新时间:2023-11-01 13:15:43 27 4
gpt4 key购买 nike

因为VLC conflict我必须在应用程序启动时关闭 Windows 高级文本服务。有什么特殊的API吗?它适用于具有默认权限的用户吗?

最佳答案

问题的标题是“禁用 Windows 服务...”,但答案都告诉了如何停止服务。

您会在 Google 上找到的大部分内容是您可以更新注册表以使用如下方式禁用服务:

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\[YourServiceName]", true);
key.SetValue("Start", 4);

我还没有尝试过这种方法,但看起来好像行得通。我还想出了一个不同的方法,使用 sc.exe 来禁用服务:

Process sc = Process.Start("sc.exe", "config [YourServiceName] start= disabled");

关于c# - 在应用程序启动时禁用 Windows 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3052649/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com