在Windows 7 C#上运行exe文件 [英] Run exe file on windows 7 C#
问题描述
我试过运行一个exe文件,代码如下:
I have tried to run an exe file the code is given below
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace ApplicationShield
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
try
{
string path;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = @"\\192.168.0.1\\public\\Akmal\\IBTalk_Screenshare.exe";
p.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
MessageBox.Show("Installation Canceled");
}
}
}
}
现在当我发布项目,结果在系统上安装了一个表单,但是当我单击按钮时它会显示异常
System.ComponenetModel.Win32Exception网络名称无法找到
System.Diagnostic.Process.StartWithShellExecuteEx(ProcessStartInfo,StartInfo)
在System.Diagnostic.Process.Start(ProcessStartInfo,StartInfo)
在ApplicationShield.Form1.Button1_Click(Object sender,EventArgs e)
它在Windows XP上运行完美,但它在Windows 7中显示上述异常
Now when i publish the project , In the result a form is installed on the system , but when i click the button it show me the exception
System.ComponenetModel.Win32Exception The Network name cannot be found at
System.Diagnostic.Process.StartWithShellExecuteEx(ProcessStartInfo,StartInfo)
at System.Diagnostic.Process.Start(ProcessStartInfo,StartInfo)
at ApplicationShield.Form1.Button1_Click(Object sender,EventArgs e)
it runs perfectly on Windows XP but it show the above mentioned Exception in windows 7
推荐答案
更改:
Hi,
Change:
p.StartInfo.FileName = @"\\192.168.0.1\\public\\Akmal\\IBTalk_Screenshare.exe";
成:
into:
p.StartInfo.FileName = @"\\192.168.0.1\public\Akmal\IBTalk_Screenshare.exe";
希望这有帮助。
Hope this helps.
这篇关于在Windows 7 C#上运行exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!