CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    192

    Kill an executable File subroutine

    Hallo,

    I would like to write a sub routine to kill an executable file called 'dfsvc.exe'. I'll call this subroutine when I exit my application to kill this file. When I exit my application this file is still running and takes around 15 minutes before it disappears. I would like to kill it to remove the delay.. The following code below doesnt work.. any ideas please


    Private Sub Kill()

    Dim aProcess As System.Diagnostics.Process

    aProcess = System.Diagnostics.Process.GetProcessesByName("dfsvc.exe")

    aProcess.Kill()

    End Sub


    Thanks

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Kill an executable File subroutine

    What you have written kills the process, and not the actual file.

    Try looking into the System.IO namespace and then using the File.Delete method.

    If the exe is running, you might battle to delete it...

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

Featured