我想通过服务运行用c#winform制作的应用程序。我已经完成了代码,但是即使服务成功启动,应用程序也没有启动并且没有抛出异常。
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("starting Kb");
try
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = @"C:\Program Files (x86)\Invisual E. Inc\KeyboardSetup\keyboard.exe";//Exe Path
myProcess.StartInfo.CreateNoWindow = false;
myProcess.EnableRaisingEvents = true;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
myProcess.Start();
ProcessWindowStyle ws = myProcess.StartInfo.WindowStyle;
if (ws == ProcessWindowStyle.Hidden)
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
eventLog1.WriteEntry("started");
}
catch (Exception c)
{
eventLog1.WriteEntry(c.Message);
}
}
日志文件没有显示任何异常。
目的是在窗口的欢迎屏幕上启动应用程序,以便用户可以使用定制的键盘。