从Windows窗体应用程序调用exe文件 [英] calling an exe file from a Windows forms application

查看:264
本文介绍了从Windows窗体应用程序调用exe文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用的是windows server2008 r2和visual studio 2010



1)我开发了一个Windows窗体应用程序,它有一些文本框和按钮。

2)我使用visual studio安装程序构建了一个安装项目。



问题:

现在我有了将setup.exe / msi包添加到表单应用程序。一旦用户点击特定按钮,setup.exe / msi包就应该开始安装。我已经搜索了许多论坛,但得到了这个解决方案。



处理p =  new  Process(); 
p.StartInfo.FileName = @ exe\setup.exe的路径 ;
p.Start();





如果用户计算机具有setup.exe文件,则此解决方案很好。但我的问题是,当我们将它提供给客户端时,他们将不会在他们的机器上安装setup.exe。所以这种提到路径的方式将无法解决。我需要一个解决方案,其中setup.exe / msi包应该在按钮点击开始安装而不提及路径。



期待您在这种情况下的帮助。提前谢谢了。 plz帮我解决

解决方案

将setup.exe粘贴到运行表单的同一文件夹中并使用此

 p.StartInfo.FileName = Path.Combine(Application.StartupPath,  setup.exe


Hi,
I am using windows server2008 r2 and visual studio 2010

1) I have developed a windows forms application which has some textboxes and buttons.
2) I have built an setup project using visual studio installer.

Problem:
Now i have added the setup.exe/msi package to the forms application. once the user clicks on a particular button the setup.exe/msi package should start its installation. i have googled many forums but got with this solution.

Process p = new Process();
    p.StartInfo.FileName = @"Path to the exe\setup.exe";
    p.Start();



This solution is good if the user machine has the setup.exe file. But my problem is when we give it to the client they will not be having the setup.exe on their machine. So this way of mentioning the path will not work out. i need a solution wherein the setup.exe/msi package should start installing on a button click without mentioning the path.

Looking forward for your help in this scenario. Many thanks in advance. plz help me out

解决方案

Paste your setup.exe in same folder where your form is running and use this

p.StartInfo.FileName = Path.Combine(Application.StartupPath, "setup.exe")


这篇关于从Windows窗体应用程序调用exe文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆