Parent Previous Next

TW.launchFile(QString pathAndFileName)

Set full path and file name.

Returns an object map with two member properties:

  "status" and "message".

There no arguments (options or switches) can be supplied see no variation will work.

This function is controlled by the Edit /Preferences/ Scripts - checkbox "allow scripts to run system commands".

Which is "off" by default.

Any directory (as  pathAndFileName) can be opened no matter what the security setting is.

  e.g. both of these work

var whatHappened = TW.launchFile("c:/TexProjects/writing");

var whatHappened = TW.launchFile("c:/TexProjects/writing/");

And local or web:—

var whatHappened = TW.launchFile("");

For a supplied filename, if the user has enabled System commands, then a file can be 'opened' or 'launched' by its system associated executable.

    1. If a document filename is supplied, it will be opened by what ever is set to handle the file type.
    2. If an executable's filename is supplied to the function the executable will be started.

1. On windows under normal default settings, notepad.exe might be expected to open this document.

var whatHappened =  launchFile("c:/to/somewherre/myFile.txt");

2. On windows under normal default settings, this usage would launch notepad.exe with a blank document showing.

var whatHappened =  launchFile("c:/windows/notepad.exe");

This type of thing will not currently work under any variation:

 var whatHappened =  TW.launchFile("c:/windows/notepad.exe c:/hold/MyFile.txt"

Return Values

The function returns an object with two member properties:

  "status" and "message"

The following tables list the return values for whatHappened

 whatHappened["status"] —  


Integer returned


on success



on file access failure (e.g. wrong name supplied)



if Preference Permission not set by User yet



 whatHappened["message"]  —


String Returned

on success

a blank message - empty string

on file access failure (e.g. wrong name)

""c:/to/somewherre/myFile.txt" could not be opened."

if Preference Permission not set by User yet

"System command execution is disabled (see Preferences)"

Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation