Last active
September 13, 2016 15:47
-
-
Save jbratu/923881c5fa85bac385406a5a01a8ef51 to your computer and use it in GitHub Desktop.
OpenInsight sample snippet to show how any recognized file on the system can be opened by the file extension's registered application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function CS_LAUNCH_FILE_SNIPPET(void) | |
| *Common to hold our control between runs so it isn't re-initialized on each call | |
| common /wscript_launch_control/ wsLauncher, wsLauncherAssigned | |
| If Assigned(wsLauncherAssigned) Else wsLauncherAssigned = '' | |
| If wsLauncherAssigned Else | |
| *Control not initialized, do it now | |
| *VBScript to run | |
| sc = '' | |
| sc<-1> = 'sub launch(File)' | |
| sc<-1> = 'CreateObject("WScript.Shell").Run(File)' | |
| sc<-1> = 'end sub' | |
| *Setup the control | |
| wsLauncher = OLECreateInstance("MSScriptControl.ScriptControl") | |
| wsLauncher->Language = "VBScript" | |
| Swap @FM With \0D0A\ In sc | |
| *Add the VBScript to the control | |
| x = wsLauncher->AddCode(sc) | |
| sc = '' | |
| wsLauncherAssigned = 1 ;*Mark the launcher has been setup | |
| End | |
| *Path of the file to open | |
| FilePath = "C:\temp\test.csv" | |
| *Run the control's VBScript to launch the file. | |
| *Protect the FilePath in quotes in case of spaces in path | |
| x = wsLauncher->Run('launch', '"' : FilePath : '"') | |
| Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment