编程语言
首页 > 编程语言> > c# – 没有Process.start打开网站

c# – 没有Process.start打开网站

作者:互联网

如何在没有Process.start(…)的情况下在浏览器中打开网站URL:

System.Diagnostics.Process.Start(@"http://www.google.com");

我无法在Windows服务中使用Process.Start(),我不知道为什么.

解决方法:

请参阅问题“How can a Windows service execute a GUI application?”的答案:

use WTSEnumerateSessions to find the right desktop, then CreateProcessAsUser to start the application on that desktop

还要注意你不应该这样做:)

如果你要做的只是启动一个URL,那么命令可能是

cmd.exe /c start http://example.com/

如果要禁止短暂显示的命令提示符窗口,可以将STARTUPINFO structure的wShowWindow字段设置为SW_HIDE,或者在.NET中将ProcessStartInfo.WindowStyle属性设置为ProcessWindowStyle.Hidden.

标签:c,process,external-process
来源: https://codeday.me/bug/20190711/1437471.html