Closing a running executable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mg

    Closing a running executable

    System.Diagnost ics.Process.Sta rt("c:\\windows \\system32\\not epad.exe","c:\\ x.txt");

    Will launch x.txt in notepad

    What code will close this instance of notepad?
  • Shiva

    #2
    Re: Closing a running executable

    Process.Start() returns a Process instance. Call CloseMainWindow () or Kill()
    on the returned instance.

    "mg" <mg@discussions .microsoft.com> wrote in message
    news:8FDB3B4F-03B6-4772-A075-8D1CFD41C4A1@mi crosoft.com...
    System.Diagnost ics.Process.Sta rt("c:\\windows \\system32\\not epad.exe","c:\\ x
    ..txt");

    Will launch x.txt in notepad

    What code will close this instance of notepad?


    Comment

    • mg

      #3
      Re: Closing a running executable

      Thank you.


      "Shiva" wrote:
      [color=blue]
      > Process.Start() returns a Process instance. Call CloseMainWindow () or Kill()
      > on the returned instance.
      >
      > "mg" <mg@discussions .microsoft.com> wrote in message
      > news:8FDB3B4F-03B6-4772-A075-8D1CFD41C4A1@mi crosoft.com...
      > System.Diagnost ics.Process.Sta rt("c:\\windows \\system32\\not epad.exe","c:\\ x
      > ..txt");
      >
      > Will launch x.txt in notepad
      >
      > What code will close this instance of notepad?
      >
      >
      >[/color]

      Comment

      • mg

        #4
        Re: Closing a running executable


        The following 2 lines open a text file in notepad and then close notepad:

        System.Diagnost ics.Process pr =
        System.Diagnost ics.Process.Sta rt("c:\\windows \\system32\\not epad.exe","c:\\ x.txt");

        pr.CloseMainWin dow();

        But, the following 2 lines open a pdf file in the Acrobat reader, which
        remains open:

        System.Diagnost ics.Process pr =
        System.Diagnost ics.Process.Sta rt("c:\\progra m files\\adobe\\a crobat
        6.0\\reader\\ac rord32.exe",@"/t ""c:\exportfile s\d.pdf"" ""HP LaserJet 3300
        Series PCL 6"" ""HP LaserJet 3300 Series PCL 6"" ""DOT4_001" "");

        pr.CloseMainWin dow();

        How can I close the Acrobat reader?


        "Shiva" wrote:
        [color=blue]
        > Process.Start() returns a Process instance. Call CloseMainWindow () or Kill()
        > on the returned instance.
        >
        > "mg" <mg@discussions .microsoft.com> wrote in message
        > news:8FDB3B4F-03B6-4772-A075-8D1CFD41C4A1@mi crosoft.com...
        > System.Diagnost ics.Process.Sta rt("c:\\windows \\system32\\not epad.exe","c:\\ x
        > ..txt");
        >
        > Will launch x.txt in notepad
        >
        > What code will close this instance of notepad?
        >
        >
        >[/color]

        Comment

        • Grigs

          #5
          Re: Closing a running executable

          I needed to do this same thing and have been searching for it. I thank you
          for having the issue prior to me. I did however figure out how to get the
          Acrobat window to disappear. Just do the following...

          pr.CloseMainWin dow();
          pr.Close();

          Apparently doing both completely clears everything.
          Kevin


          "mg" wrote:
          [color=blue]
          >
          > The following 2 lines open a text file in notepad and then close notepad:
          >
          > System.Diagnost ics.Process pr =
          > System.Diagnost ics.Process.Sta rt("c:\\windows \\system32\\not epad.exe","c:\\ x.txt");
          >
          > pr.CloseMainWin dow();
          >
          > But, the following 2 lines open a pdf file in the Acrobat reader, which
          > remains open:
          >
          > System.Diagnost ics.Process pr =
          > System.Diagnost ics.Process.Sta rt("c:\\progra m files\\adobe\\a crobat
          > 6.0\\reader\\ac rord32.exe",@"/t ""c:\exportfile s\d.pdf"" ""HP LaserJet 3300
          > Series PCL 6"" ""HP LaserJet 3300 Series PCL 6"" ""DOT4_001" "");
          >
          > pr.CloseMainWin dow();
          >
          > How can I close the Acrobat reader?
          >
          >
          > "Shiva" wrote:
          >[color=green]
          > > Process.Start() returns a Process instance. Call CloseMainWindow () or Kill()
          > > on the returned instance.
          > >
          > > "mg" <mg@discussions .microsoft.com> wrote in message
          > > news:8FDB3B4F-03B6-4772-A075-8D1CFD41C4A1@mi crosoft.com...
          > > System.Diagnost ics.Process.Sta rt("c:\\windows \\system32\\not epad.exe","c:\\ x
          > > ..txt");
          > >
          > > Will launch x.txt in notepad
          > >
          > > What code will close this instance of notepad?
          > >
          > >
          > >[/color][/color]

          Comment

          Working...