Killing a process

vanwerovanwero Member Posts: 28
edited 2004-05-18 in Navision Attain
Hi,

does anybody know how you can kill a running program from within code?

Ex: how can I end the Acrobat Reader from within Navision Code?
(Without working with "automation". Just an independent program!)


Thanks a lot!!

Greets,
R.

Comments

  • GoMaDGoMaD Member Posts: 313
    pskill should do the trick

    It comes with the Windows SDK toolkit.

    Greetings,
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • Rob_HansenRob_Hansen Member Posts: 296
    I needed to accomplish this for some functionality that triggered Acrobat reader sessions from within Navision. I ended up writing a VB DLL with a function to kill all instances of Acrobat...obviously you just need to be careful that the user doesn't have any other valid Acrobat sessions open (I'll leave that to you to handle!). And the other downside is needing to install a DLL on each workstation. Anyway, the function itself is:


    Private Function KillAcrobatSessions()
    On Error GoTo FunctionErr

    Dim wmi, wmiq, colProcesses, process As Object

    'Kill any acrobat sessions
    Set wmi = GetObject("winmgmts:")
    '-- Query for active acrobat reader processes
    wmiq = "select * from Win32_Process where name='AcroRd32.exe'"
    Set colProcesses = wmi.ExecQuery(wmiq)
    For Each process In colProcesses
    process.Terminate (1)
    Next
    Set colProcesses = Nothing
    Set wmi = Nothing

    FunctionErr:
    End Function
Sign In or Register to comment.