Page 1 of 1

How to launch an external program

Posted: Thu Jul 17, 2008 7:34 pm
by jerome
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.

Re: how to launch an external program

Posted: Thu Jul 17, 2008 7:58 pm
by squenson
From the excellent A. Pitonyak's e-book (section 5.33), I manage to launch any program:

Code: Select all

  Dim oSvc as object
  oSvc = createUnoService("com.sun.star.system.SystemShellExecute")

  Rem Launch notepad
  oSvc.execute(ConvertToUrl("C:\windows\notepad.exe"), "", 0)

Re: how to launch an external program

Posted: Fri Nov 03, 2017 2:49 am
by arfgh
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 ....

Re: how to launch an external program

Posted: Fri Nov 03, 2017 8:25 am
by Zizi64
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.

Re: how to launch an external program

Posted: Fri Nov 03, 2017 2:28 pm
by arfgh
example of use of that ?

Re: how to launch an external program

Posted: Fri Nov 03, 2017 8:03 pm
by Zizi64
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.
viewtopic.php?f=20&t=57390
https://wiki.openoffice.org/wiki/Docume ... tarDesktop
http://ooo-forums.apache.org/en/forum/v ... 20&t=38778
...etc...

Re: how to launch an external program

Posted: Sat Nov 04, 2017 1:54 am
by Jurassic Pork
hello,
with the extension EasyDev (see here) it's easy :) :
to compress some files and see the crc :

Code: Select all

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

Re: how to launch an external program

Posted: Sat Nov 04, 2017 1:57 am
by arfgh
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 ?

Re: how to launch an external program

Posted: Sat Nov 04, 2017 2:03 am
by Jurassic Pork
certainly but it will be more complicated or use a python macro

Re: how to launch an external program

Posted: Sat Nov 04, 2017 2:06 am
by arfgh
i see that you used the 'special msgbox' from EasyDev to show the results.
Exist that documentation in pdf ?