How to launch an external program

Java, C++, C#, Delphi, ??? - Using the UNO bridges

How to launch an external program

Postby jerome » Thu Jul 17, 2008 7:34 pm

Hello,

In VBA, I used the following code in order to launch an external program:
----
cmd = q & VBA.Environ("SystemRoot") & "\system32\cmd.exe" & q & " /c " & drive & " && cd " & q & procPath & q & " && launch.bat"
VBA.Shell cmd, vbHide
----

I could not find how to do the same with OOBasic.

Thanks for your help.
jerome
 
Posts: 2
Joined: Thu Jul 17, 2008 7:23 pm

Re: how to launch an external program

Postby squenson » Thu Jul 17, 2008 7:58 pm

From the excellent A. Pitonyak's e-book (section 5.33), I manage to launch any program:
Code: Select all   Expand viewCollapse view
  Dim oSvc as object
  oSvc = createUnoService("com.sun.star.system.SystemShellExecute")

  Rem Launch notepad
  oSvc.execute(ConvertToUrl("C:\windows\notepad.exe"), "", 0)
LibreOffice 4.2.3.3. on Ubuntu 14.04
User avatar
squenson
Volunteer
 
Posts: 1885
Joined: Wed Jan 30, 2008 9:21 pm
Location: Lausanne, Switzerland

Re: how to launch an external program

Postby arfgh » Fri Nov 03, 2017 2:49 am

question, and very interesting...

if we run for example the '7za' (7-zip cmd program) command-line program, can we also capture its exit ?
the end is the DB file integrity check.

Highly interesting in my opinion ....
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: how to launch an external program

Postby Zizi64 » Fri Nov 03, 2017 8:25 am

if we run for example the '7za' (7-zip cmd program) command-line program, can we also capture its exit ?

Just a foggy idea:
If you can parametrize the launching command of the software to launch, then you can control the place: where to unpack the file/s/.
And then you can load the extracted file from the known URL by the "LoadComponentFromURL()" API function (as a return value of the function) into an Object type variable.
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.7 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.3 and AOO4.1.4
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 6083
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: how to launch an external program

Postby arfgh » Fri Nov 03, 2017 2:28 pm

example of use of that ?
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: how to launch an external program

Postby Zizi64 » Fri Nov 03, 2017 8:03 pm

example of use of that ?

I do not know anything about the parameters of the launch command of the '7za' (7-zip cmd program) command-line program. I suppose that you need pass two parameters: the URL of the file to unpack, and the URL or path of the target file/directory.


About the LoadComponentFromURL(): There are many examples in this forum. Search them.
https://forum.openoffice.org/en/forum/v ... 20&t=57390
https://wiki.openoffice.org/wiki/Docume ... tarDesktop
http://ooo-forums.apache.org/en/forum/v ... 20&t=38778
...etc...
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.7 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.3 and AOO4.1.4
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 6083
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: how to launch an external program

Postby Jurassic Pork » Sat Nov 04, 2017 1:54 am

hello,
with the extension EasyDev (see here) it's easy :) :
to compress some files and see the crc :
Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****
Sub Tst_7za()
util = createUnoService("org.universolibre.EasyDev")
res = util.execute(Array("cmd.exe","/c","F:\7zip\7za.exe",_
      "a","F:\temp\Files.7z","F:\temp\*.txt"), True)
util.msgbox(res)
res = util.execute(Array("cmd.exe","/c","F:\7zip\7za.exe",_
      "h","F:\temp\Files.7z"), True)
util.msgbox(res)
End Sub


tst-7za-1.png
tst-7za-2.png



Friendly, J.P
OpenOffice 4.1.3 , LibreOffice 5.2.7.2 on Windows 7 / LibreOffice 5.4.2.2 on Ubuntu 16.04
User avatar
Jurassic Pork
 
Posts: 5
Joined: Wed Oct 25, 2017 7:55 am
Location: France

Re: how to launch an external program

Postby arfgh » Sat Nov 04, 2017 1:57 am

well, the end was just to check the own .odb document integrity... and yes you are using an extenion, exist no way to do it without another extension ?
Anyways, what's the purpose of EasyDev ?
Last edited by arfgh on Sat Nov 04, 2017 2:05 am, edited 1 time in total.
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm

Re: how to launch an external program

Postby Jurassic Pork » Sat Nov 04, 2017 2:03 am

certainly but it will be more complicated or use a python macro
OpenOffice 4.1.3 , LibreOffice 5.2.7.2 on Windows 7 / LibreOffice 5.4.2.2 on Ubuntu 16.04
User avatar
Jurassic Pork
 
Posts: 5
Joined: Wed Oct 25, 2017 7:55 am
Location: France

Re: how to launch an external program

Postby arfgh » Sat Nov 04, 2017 2:06 am

i see that you used the 'special msgbox' from EasyDev to show the results.
Exist that documentation in pdf ?
OpenOffice last version - Windows 8.1 Enterprise x64 - Windows XP x64 SP2
arfgh
 
Posts: 350
Joined: Tue Mar 05, 2013 6:44 pm


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests