Feeds:
Posts
Comments

Posts Tagged ‘EXE’

To run an exe from your web page is quite easy process. I have used simple JavaScript to accomplish this task. Have a look at the code listed below.

function WriteToFile() {

var fso, s,folderName;

fso = new ActiveXObject("Scripting.FileSystemObject");

if (!fso.FolderExists("C:\\HITESH"))

{

folderName=fso.CreateFolder("C:\\ HITESH ");

}

if (!fso.FileExists("C:\\ HITESH \\LaunchApp.bat")){

s = fso.OpenTextFile("C:\\ HITESH \\LaunchApp.bat" , 8, 1, -2);

s.writeline("IF EXIST d:\\hitesh GOTO LABEL1”);

s.writeline("IF EXIST k:\\hitesh GOTO LABEL2”);

s.writeline(":LABEL1”);

s.writeline("D: ”);

s.writeline("D:\\hitesh\\AppTest.EXE”);

s.writeline("EXIT”);

s.writeline(":LABEL2”);

s.writeline("K: ”);

s.writeline("K:\\hitesh\\AppTest.EXE”);

s.writeline("EXIT”);

s.Close();

}

}

function LaunchApp() {

WriteToFile();

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

var prog = "C:\\ HITESH \\LaunchApp.bat";

oShell.run ('"'+prog+'"',1);

}

This javascript will create an object of WScript.Shell and will execute DOS based batch file. In addition with this I have also created LaunchApp.bat file programmatically if it does not exist on the client side (So you don’t need to worry about whether file exist or not J). This file will execute EXE depending upon conditions specified in the LaunchApp.bat. LaunchApp() is the starting point.

Advertisements

Read Full Post »