[Solved] How to kill proces

Creating a macro - Writing a Script - Using the API

[Solved] How to kill proces

Postby lodovi » Sun May 05, 2019 5:50 pm

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
lodovi
 
Posts: 15
Joined: Fri May 13, 2016 2:23 pm

Re: How to kill proces

Postby Bidouille » Mon May 06, 2019 9:22 am

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.
User avatar
Bidouille
Volunteer
 
Posts: 270
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: How to kill proces

Postby lodovi » Mon May 06, 2019 9:33 am

How can I get PID?
LibreOffice 5.2.2.2. OS Win 7
lodovi
 
Posts: 15
Joined: Fri May 13, 2016 2:23 pm

Re: How to kill proces

Postby JeJe » Mon May 06, 2019 12:01 pm

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)
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 552
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to kill proces

Postby hubert lambert » Mon May 06, 2019 1:30 pm

Hi,

This single line shoud work ("shell" is a basic runtime command):
Code: Select all   Expand viewCollapse view
    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
hubert lambert
 
Posts: 129
Joined: Mon Jun 13, 2016 10:50 am

Re: How to kill proces

Postby lodovi » Mon May 06, 2019 7:28 pm

Super, super, super :) It works absolutly great. Thank you very much everybody and especially hubert lambert
LibreOffice 5.2.2.2. OS Win 7
lodovi
 
Posts: 15
Joined: Fri May 13, 2016 2:23 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 8 guests