ShellExecute equivalent in .NET

C#.NetWinapiWindows ShellShellexecute

C# Problem Overview


I'm looking for the .NET-preferred way of performing the same type of thing that ShellExecute does in Win32 (opening, printing, etc. for arbitrary file types).

I've been programming Windows for over 20 years, but I'm a complete newbie at .NET, so maybe I'm just looking in the wrong places. I'm currently using .NET 2.0 (VS C# 2005), but could use VS 2008 if need be.

If the only answer is to use P/Invoke, then I might be better just writing my small utility using Win32 anyway.

C# Solutions


Solution 1 - C#

Process.Start.

Note that advanced uses (printing etc) require using a ProcessStartInfo and setting the Verb property.

Solution 2 - C#

System.Diagnostics.Process.Start(command)

I bet you had trouble finding it because it is in the System.Diagnostics namespace. "Diagnostics"? Usually with 20 years experience one thing you get good at is guessing at what something will be called in a new API/language, but this one tricked me.

Solution 3 - C#

Did you try System.Diagnostics.Process.Start() function... It's more or less similar to ShellExecute. You can open exes, documents. I haven't checked printing yet, Marc has told you how already.

Solution 4 - C#

System.Diagnostics.Process.Start("explorer.exe", path);

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMartin KennyView Question on Stackoverflow
Solution 1 - C#Marc GravellView Answer on Stackoverflow
Solution 2 - C#Corey TragerView Answer on Stackoverflow
Solution 3 - C#Cyril GuptaView Answer on Stackoverflow
Solution 4 - C#mdimai666View Answer on Stackoverflow