[Solved] How to kill proces

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
lodovi
Posts: 15
Joined: Fri May 13, 2016 2:23 pm

[Solved] How to kill proces

Post by lodovi »

Hi, I'd like to use a macro to stop running an acrobat reader before creating a pdf.
I'm trying something like that :
oSys = CreateUnoService("com.sun.star.system.SystemShellExecute")
oSys.execute("C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe","",0)
oSys.execute("C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe", "kill",1)

or like this
shell("pkill C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe")

Or close the open file directly
address = ConvertToUrl(sPATH)
shell("pkill" & address)

The problem is that I want to overwrite the open PDF file, so I must close it first, otherwise the program ends with an error.

I don't know Shell at all, I'm just trying.
Can anyone help? Thanks
Last edited by lodovi on Mon May 06, 2019 9:54 pm, edited 2 times in total.
LibreOffice 5.2.2.2. OS Win 7
Bidouille
Volunteer
Posts: 574
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: How to kill proces

Post by Bidouille »

This question should be posted in macro area.

What is pkill? You want run a Unix command under Windows.
Remember that this kind of tool wait a PID and not a pathname.
lodovi
Posts: 15
Joined: Fri May 13, 2016 2:23 pm

Re: How to kill proces

Post by lodovi »

How can I get PID?
LibreOffice 5.2.2.2. OS Win 7
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to kill proces

Post by JeJe »

There's a couple of suggestions here:

https://stackoverflow.com/questions/183 ... n-from-vb6

http://www.vbforums.com/showthread.php? ... pplication

(vb6 code can often work or be adapted to OO so do a search for VB6 and what you want and you may get a solution)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: How to kill proces

Post by hubert lambert »

Hi,

This single line shoud work ("shell" is a basic runtime command):

Code: Select all

    shell("taskkill", 0, "/f /im AcroRd32.exe", True)
More info on "taskkill": https://docs.microsoft.com/en-us/window ... s/taskkill.

Regards.
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
lodovi
Posts: 15
Joined: Fri May 13, 2016 2:23 pm

Re: How to kill proces

Post by lodovi »

Super, super, super :) It works absolutly great. Thank you very much everybody and especially hubert lambert
LibreOffice 5.2.2.2. OS Win 7
Post Reply