.Net Core 2.0 Process.Start throws “The specified executable is not a valid application for this OS platform”

跟風遠走 提交于 2019-11-29 09:09:26

You have to execute cmd.exe

var proc = Process.Start(@"cmd.exe ",@"/c C:\Users\user2\Desktop\XXXX.reg")

don't forget the /c

You can also set the UseShellExecute property of ProcessStartInfo to true

var p = new Process();
p.StartInfo = new ProcessStartInfo(@"C:\Users\user2\Desktop\XXXX.reg")
{ 
    UseShellExecute = true 
};
p.Start();

Seems to be a change in .net Core, as documented here.

You can set UseShellExecute to true and include this and your path in a ProcessStartInfo object:

Process.Start(new ProcessStartInfo((@"C:\Users\user2\Desktop\XXXX.reg") { UseShellExecute = true });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!