简体   繁体   English

不同用户的System.Diagnostics.Process.Start异常

[英]System.Diagnostics.Process.Start Exception for different user

I created an exe application with a button which has the following code executed when clicked. 我创建了一个带有按钮的exe应用程序,单击该按钮将执行以下代码。 It is working when clicked by the same user which is used to create the exe. 当用于创建exe的同一用户单击时,它可以正常工作。 But the same exe when clicked by other users get exception message as "Application not found" . 但是当其他用户单击相同的exe时,会得到异常消息"Application not found" Also the stack trace looks like given below. 堆栈跟踪也如下所示。

        try
        {                
            System.Diagnostics.Process.Start("https://google.com");
        } catch(Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

Exception: 例外:

    Exception Info: System.ComponentModel.Win32Exception
   at System.Diagnostics.Process.StartWithShellExecuteEx(System.Diagnostics.ProcessStartInfo)
   at System.Diagnostics.Process.Start(System.Diagnostics.ProcessStartInfo)
   at MyTool.MainWindow.MyButton_Click(System.Object, System.Windows.RoutedEventArgs)

Maybe the other users that are running your .exe don't have a default browser or application to run this command. 可能其他正在运行您的.exe的用户没有默认的浏览器或应用程序来运行此命令。 You can validate my theory if you execute the command in Run (Windows+R) and you encounter an error. 如果在“运行”(Windows + R)中执行命令并且遇到错误,则可以验证我的理论。

You're trying to start application named " https://google.com ". 您正在尝试启动名为“ https://google.com ”的应用程序。 You need to start web-browser application with parameter as URL: 您需要使用参数作为URL启动Web浏览器应用程序:

System.Diagnostics.Process.Start("chrome.exe", "https://google.com");

Or with other application name. 或带有其他应用程序名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM