.bat file opens writer not as excutable file

Libreoffice 6.1.3 and this micro used in standalone to open .odt form
i am using below micro and insert in event open document to open on load but .bat file opens in writer not as executable file

sub openserver

dim sUrl as string
dim oDoc as object, oDocFrame as object, dispatcher as object
dim PropVal(0) as new com.sun.star.beans.PropertyValue
dim args(0) as new com.sun.star.beans.PropertyValue

sUrl = convertToUrl("C:\Test\server.bat")

oDoc = stardesktop.LoadComponentFromURL(sUrl, "_blank", 0, Array())

oDocFrame = oDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

end sub

please help out

.bat implies windows. What’s the text inside your .bat file?

Hello,

The file is opened by Writer because it is a basically a text file & you have simply asked that the file be opened with LO.

If you want to execute a process outside of LO you should be using the Shell command. Have tested this (starting HSQLDB server) in Linux Mint (uses .sh not .bat) with the following macro:

Sub Main_Open
    Dim sFileName as String
  Rem This works on Mint 18
    sFileName = "/home/linuxnow/a/hsqldbstart.sh"
    shell "bash -c 'sh " & sFileName & "'"
  Rem Arbitrary amount of time for startup of server - may be OK with less time set
    Wait 5000        '5 seconds'
End Sub

You will most likely want something similar to shut down the server.

Keep in mind the above Shell command is for Linux. You need to adjust the Shell string for your .bat file processing.