Results 1 to 10 of 10

Thread: [RESOLVED] ShellExecute

  1. #1

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345

    [RESOLVED] ShellExecute

    How can I open a file with it's default program in a similar way to how I would use ShellExecute in VB6?

    Thanks
    Last edited by TomGibbons; Dec 26th, 2003 at 01:44 PM.

  2. #2
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    You`ll need to call a new process:

    Code:
    Process showWordDoc = new Process();
    showWordDoc.StartInfo.FileName = @"c:\myPath\myDoc.doc";
    //showWordDoc.StartInfo.Arguments= ""; here you can put startup arguments
    showWordDoc.StartInfo.UseShellExecute = true;
    showWordDoc.Start();
    showWordDoc.WaitForExit();
    showWordDoc.Close();
    I think you will need to include "using System.Diagnostics;" in order to work.

    BTW: there are a lot more otions than the ones I posted, just look into them, all easy to understand.

    HTH, Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Sgt-Peppa, that is too much crap. He doesn't need all that just to execute a file

    Process.Start("My.html")

    done

  4. #4
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Sgt-Peppa, that is too much crap. He doesn't need all that just to execute a file
    WOW was not aware of that, it works !

    I never opend up a file,.. just called a lot of processes and needed to pass arguments.
    So i thought thats the way to do it, you proved me wrong, and I learned, thanks

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  5. #5

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    Originally posted by kasracer
    Sgt-Peppa, that is too much crap. He doesn't need all that just to execute a file

    Process.Start("My.html")

    done
    I get "The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?)"

    Do I need a "using..."?

  6. #6
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Originally posted by Sgt-Peppa


    I think you will need to include "using System.Diagnostics;" in order to work.

    HTH, Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  7. #7

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    Ahh I thought that was just for your example. Thank you both

  8. #8
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Sgt-Peppa
    WOW was not aware of that, it works !

    I never opend up a file,.. just called a lot of processes and needed to pass arguments.
    So i thought thats the way to do it, you proved me wrong, and I learned, thanks

    Stephan
    lol no problem.

    I think the full path, so you don't have to include System.Diagnostics is like

    System.Diagnostics.Process.Start("OMG.vb")

  9. #9
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108
    was that sarcasm or truth?
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

  10. #10
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Danny J
    was that sarcasm or truth?
    uh?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width