Friday, July 3, 2015

Launch Application exe with Javascript.

Sample code to launch the application exe from the Javascript.

Code:

     var ws = new ActiveXObject("WScript.Shell");

     ws.Exec("C:\\TestApp.exe");

Read & Write a File with JavaScript

Sample code to do the File manipulation in JavaScript.
This code illustrate, how to Create, Read & Write the text in file using the Java Script.

Code:

           // Reading text file.

           var fso  = new ActiveXObject("Scripting.FileSystemObject");
           var fhRead = fso.OpenTextFile("C:\\Test.txt",1);
           var Fltext = fhRead.ReadAll();
           fhRead.Close();
 

            // Creating text file.

            var fh = fso.CreateTextFile("C:\\Test.txt", true);
            fh.WriteLine("Sample");
            fh.Close();