|
-
June 30th, 2004, 11:45 AM
#1
how to execute an .exe in c#
Hi,
I'm a newbie to c#, i'm writing an app. in asp.net using C#. One of the things that i want to do is execute a command. In particular, there is a file on a network share that i want to execute, "somefile.exe" . How do i write code in C# to execute that file?
Thanks
Sharon
-
June 30th, 2004, 12:03 PM
#2
-
June 30th, 2004, 12:56 PM
#3
Hi,
Thanks for the response. I'm getting a server error message when I run the app,
Code:
"Logon failure: unknown user name or bad password"
Exception Details: System.ComponentModel.Win32Exception: Logon failure: unknown user name or bad password
I'm assuming since the file is on a network share, i'll need to authenticate myself when I try to execute the file. Can someone please tell me how to do this?
Thanks
Sharon
-
July 1st, 2004, 05:10 AM
#4
if passing arguments to the process is what you need then maybe this example will help you:
Code:
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
public class MyProcess
{
/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
public void OpenApplication(string myFavoritesPath)
{
// Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe");
// Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath);
}
/// <summary>
/// Opens urls and .html documents using Internet Explorer.
/// </summary>
public void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}
/// <summary>
/// Uses the ProcessStartInfo class to start new processes, both in a minimized
/// mode.
/// </summary>
public void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
public static void Main()
{
// Get the path that stores favorite links.
string myFavoritesPath =
Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
MyProcess myProcess = new MyProcess();
myProcess.OpenApplication(myFavoritesPath);
myProcess.OpenWithArguments();
myProcess.OpenWithStartInfo();
}
}
}
Mr. Burns
-
July 2nd, 2004, 10:56 AM
#5
Hi,
Thanks for the response. But i'm looking for a way to authenticate the application when it goes and accesses a file using process.start method (since the file is on a windows share).
The app. will be running on a network and it will require login name and password in order to access the file, which is why i'm receiving the server error message. i'm still stumped as how to do this as i'm looking at the StartInfo of the process class and the FileName property but it doesn't have fields to specify login and password to access file...
Thanks in advance.
Sharon
-
July 3rd, 2004, 10:35 AM
#6
how about creating a connection to that network first, and then you can simply lauch that file... if a connection is created, no need to authenticate again...
Regards,
Alexei
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|