目前,用户必须进入控制面板>程序>打开或关闭Windows功能,然后单击要激活的功能的复选框.我想让他们能够从我的应用程序中执行此操作.
有关如何通过.NET自动化此过程的任何想法(最好是在C#中)?
我有以下简单的服务程序:
using System.Diagnostics;
using System.ServiceProcess;
namespace BasicService
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
Verb = "runas",
UserName = "jdoe",
Password = "XXXXXXX".ConvertToSecureString(),
Domain = "abc.com",
UseShellExecute =false,
FileName = "notepad.exe"
};
Process.Start(processStartInfo);
}
protected override void OnStop()
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用它作为我的服务安装程序:
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
namespace BasicService
{
[RunInstaller(true)]
public class ProjectInstaller : Installer
{
private readonly ServiceProcessInstaller …
Run Code Online (Sandbox Code Playgroud) 嗨,我试图通过EasyNetQ通过RabbitMQ发送一个简单的对象.我在订阅方面反序列化该对象时遇到问题.任何人都能告诉我一个如何工作的样本.请记住,正在发送的对象是在其自己的项目中定义的,而不是在发布者和订阅者之间共享.这是我的样本,也许你可以告诉我它有什么问题?
计划A:
class ProgramA
{
static void Main(string[] args)
{
using (var bus = RabbitHutch.CreateBus("host=localhost"))
{
Console.WriteLine("Press any key to send the message");
Console.ReadKey();
bus.Publish(new MessageA { Text = "Hello World" });
Console.WriteLine("Press any key to quit");
Console.ReadKey();
}
}
public class MessageA
{
public string Text { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
方案B:
class ProgramB
{
static void Main(string[] args)
{
using (var bus = RabbitHutch.CreateBus("host=localhost"))
{
bus.Subscribe<MessageB>("", HandleClusterNodes);
Console.WriteLine("Press any key to quit");
Console.ReadKey();
}
}
private static …
Run Code Online (Sandbox Code Playgroud) 我试图得到它,以便任何请求:
http://<myserver>:1234
被重定向到:
https://<myserver>:1234
我试过在模块中使用“this.RequiresHttps()”,但是当我点击 url 时http://<myserver>:1234
,浏览器只是旋转,我猜这是因为我没有NancyHost
用 HTTP URI构造。我无法将 HTTP URI 与 HTTPS URI 一起添加到 NancyHost,如下所示:
var host = new NancyHost(new Uri("http://localhost:1234"), new Uri("https://localhost:1234"));
因为我会遇到注册冲突。
有任何想法吗?
c# ×3
.net ×1
controlpanel ×1
easynetq ×1
http ×1
https ×1
localsystem ×1
nancy ×1
process ×1
rabbitmq ×1
redirect ×1
self-hosting ×1
windows ×1