Executing external application(.exe file) from windows application in C#.net
-
Hii, After searching on for auto update feature to suit my needs/project, i started developing my own auto update feature. This application basically compares the version of my file and any difference in it, it will download the newest version of that file. Now problem is , i want to fire or start an .exe application/my main application whenever i find that there is no version update . And close auto update application before starting my different application . I tried out using system.process.Diagnostic.Process method But didnt succeeded. Can anyone show me how i can open different application from my current application and close the current application before starting different application. :(
Aspiring Techie, Vishnu Nath
-
Hii, After searching on for auto update feature to suit my needs/project, i started developing my own auto update feature. This application basically compares the version of my file and any difference in it, it will download the newest version of that file. Now problem is , i want to fire or start an .exe application/my main application whenever i find that there is no version update . And close auto update application before starting my different application . I tried out using system.process.Diagnostic.Process method But didnt succeeded. Can anyone show me how i can open different application from my current application and close the current application before starting different application. :(
Aspiring Techie, Vishnu Nath
-
Proces.Start is the easiest way to start a program.
Vishnu Nath wrote:
But didnt succeeded.
Did you get an error? If so, what was the message? Can you post the code you used?
I are troll :)
Now i have changed the way i used the code. Now i use my process.start code in Program.cs file. But it is behaving in a different manner.
static void Main()
{
string appPath = applicationPath();
try
{if (checkInternetConnection() == true) { if (setXML() == true) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Update()); } else { Process.Start(appPath); } } else { Process.Start(appPath); } } catch (Exception ex) { MessageBox.Show(ex.Message); Process.Start(appPath); }
appPath is the path of main application retrieved from applicationPath() method. and setXml() is a method returning boolean value. Now if update is available. the application will fire Update Form else it will start my main app. But instead the application runs , but its control and text are not visible. When Update Form runs, Form is blank without any controls in it. I m unable to understand what happens that my controls and heading form becomes invisible during runtime. Can u sort out the problem?
Aspiring Techie, Vishnu Nath
-
Now i have changed the way i used the code. Now i use my process.start code in Program.cs file. But it is behaving in a different manner.
static void Main()
{
string appPath = applicationPath();
try
{if (checkInternetConnection() == true) { if (setXML() == true) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Update()); } else { Process.Start(appPath); } } else { Process.Start(appPath); } } catch (Exception ex) { MessageBox.Show(ex.Message); Process.Start(appPath); }
appPath is the path of main application retrieved from applicationPath() method. and setXml() is a method returning boolean value. Now if update is available. the application will fire Update Form else it will start my main app. But instead the application runs , but its control and text are not visible. When Update Form runs, Form is blank without any controls in it. I m unable to understand what happens that my controls and heading form becomes invisible during runtime. Can u sort out the problem?
Aspiring Techie, Vishnu Nath
I can't see any reason here why the Update-form would hide it's controls, unless there's some kind of weird exception. I wouldn't change the Program.cs, instead, I would have put the Process.Start code somewhere in the Update-form. Perhaps that any of the other members see a potential source of the error?
I are troll :)
-
I can't see any reason here why the Update-form would hide it's controls, unless there's some kind of weird exception. I wouldn't change the Program.cs, instead, I would have put the Process.Start code somewhere in the Update-form. Perhaps that any of the other members see a potential source of the error?
I are troll :)
Since i want either of the form to open. i.e either Update form if update is available or else my main app if there is no update. Hence i chose it to include process.start code in program.cs file. :doh:
Aspiring Techie, Vishnu Nath
-
Since i want either of the form to open. i.e either Update form if update is available or else my main app if there is no update. Hence i chose it to include process.start code in program.cs file. :doh:
Aspiring Techie, Vishnu Nath
Vishnu Nath wrote:
Since i want either of the form to open.
The check might take a while, depending on connectivity. I'd still recommend showing a form with a message "Hold on, checking for new cool stuff!". Alternatively, this worked for me; Program.cs
/// /// The main entry point for the application. /// \[STAThread\] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (true) <- perform update check here :) { System.Diagnostics.Process.Start("Calc.exe"); } else { Application.Run(new Form1()); } }
I are troll :)
-
I can't see any reason here why the Update-form would hide it's controls, unless there's some kind of weird exception. I wouldn't change the Program.cs, instead, I would have put the Process.Start code somewhere in the Update-form. Perhaps that any of the other members see a potential source of the error?
I are troll :)
Eddy Vluggen wrote:
Update-form would hide it's controls
i got my mistake, i got the reason why Update form hided its control. Its because by mistake i commented out the InitializeComponent() method in Update's constructor, that led to hiding of the controls in the form. :-O
Aspiring Techie, Vishnu Nath