.NET equivelent of WinExec or ShellExec APIs?

  • Thread starter Thread starter Chris LaJoie
  • Start date Start date
C

Chris LaJoie

I'm looking for the framework equivilent of either the ShellExec or WinExec
API. Preferably ShellExec because I can use it to launch the default
browser as well as launch executables. thanks.
 
Hi Chris,

System.Process.Start ("Foo.doc"); should do the trick.

Help topic:

ms-help://MS.MSDNVS/cpref/html/frlrfsystemdiagnosticsprocessclassstarttopic.
htm

Starts a process resource by specifying the name of a document or
application file and associates the resource with a new Process component.
public static Process Start (string);

Starts a process resource by specifying the name of an application and a
set of command line arguments, and associates the resource with a new
Process component.
public static Process Start (string, string);

Regards,
Fergus
 
I'm looking for the framework equivilent of either the ShellExec or WinExec
API. Preferably ShellExec because I can use it to launch the default
browser as well as launch executables. thanks.

excerpt from my code:

//-- setting process-options (redirect,noshell,nowindow) for mbinfo.exe
pInfo.UseShellExecute=false;
pInfo.CreateNoWindow=true;
pInfo.RedirectStandardOutput=true;

//-- setting up directory-information for execution
//-- mbinfo.exe -LOGMAX /F serverlist.txt /L email.log /O email.txt
[email protected]("Exchange 5.5", "MBInfo.Path");
pInfo.Arguments="-LOGMAX /F "(e-mail address removed)("Exchange 5.5", "MBInfo.ExtractFile")+" /L "(e-mail address removed)("Exchange 5.5",
"MBInfo.LogFile")+" /O "(e-mail address removed)("Exchange 5.5", "MBInfo.DataFile");
pInfo.FileName=pInfo.WorkingDirectory+@"\mbinfo.exe";
try
{
Log.AddEntry(false, "exchange 5.5", "starting mbinfo.exe...");
MBInfo_Exe=Process.Start(pInfo);
MBInfo_Exe.WaitForExit();
MBInfo_Output=MBInfo_Exe.StandardOutput;
Log.AddEntry(false, "exchange 5.5", "mbinfo-process exited. exit-code:"+ MBInfo_Exe.ExitCode+" output:"+MBInfo_Output.ReadToEnd());
MBInfo_Output.Close();
return true;
}
catch (Exception e)
{
Log.AddEntry(true, "exchange 5.5", "error while executing mbinfo.exe - system-message: "+
e.ToString().Replace("\r","-").Replace("\n","-"));
return false;
}
finally
{
MBInfo_Exe.Dispose();
}
}

(this is formatted, normally)

hth,

crea
 
thank you both.

Chris LaJoie

Crea-Ue. Kirdar said:
excerpt from my code:

//-- setting process-options (redirect,noshell,nowindow) for mbinfo.exe
pInfo.UseShellExecute=false;
pInfo.CreateNoWindow=true;
pInfo.RedirectStandardOutput=true;

//-- setting up directory-information for execution
//-- mbinfo.exe -LOGMAX /F serverlist.txt /L email.log /O email.txt
[email protected]("Exchange 5.5", "MBInfo.Path");
pInfo.Arguments="-LOGMAX /F "(e-mail address removed)("Exchange 5.5",
"MBInfo.ExtractFile")+" /L "(e-mail address removed)("Exchange 5.5",
"MBInfo.LogFile")+" /O "(e-mail address removed)("Exchange 5.5", "MBInfo.DataFile");
pInfo.FileName=pInfo.WorkingDirectory+@"\mbinfo.exe";
try
{
Log.AddEntry(false, "exchange 5.5", "starting mbinfo.exe...");
MBInfo_Exe=Process.Start(pInfo);
MBInfo_Exe.WaitForExit();
MBInfo_Output=MBInfo_Exe.StandardOutput;
Log.AddEntry(false, "exchange 5.5", "mbinfo-process exited. exit-code:"+
MBInfo_Exe.ExitCode+" output:"+MBInfo_Output.ReadToEnd());
 
Back
Top