C#使用命令行启动一个全屏的edge浏览器。下面直接上源码:
private void OpenApp()
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.FileName = "msedge";
startInfo.Arguments = "https://lebang2020.cn --start-fullscreen";
startInfo.UseShellExecute = true;
startInfo.RedirectStandardInput = false;
startInfo.RedirectStandardOutput = false;
startInfo.RedirectStandardError = false;
startInfo.CreateNoWindow = true;
_browserProcess = System.Diagnostics.Process.Start(startInfo);
}
运行上面代码后是不是一个全屏的浏览器就打开了?
实现说明
- 用 ProcessStartInfo 启动 msedge,在 Arguments 中加 --start-fullscreen 与目标网址。
- UseShellExecute 需设为 true,才能正确找到浏览器。
- 如需指定用户配置或窗口尺寸,可加 --user-data-dir、--window-size 等参数。
- Kiosk 展示场景可考虑 --kiosk 参数(真正的无边框模式)。