[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
How_To_Javascript_Run_Executable_On_Client
To launch an application on the client machine, place this script in the head of the HTML page.
Place this in the body of the HTML page. The button click will trigger off the function and the application is run.
Creates the WSH object as a new instance of an ActiveXObject.
The run method of WSH starts the executable program.
The first parameter passed into the run method executes the command "notepad.exe".
The second parameter is optional and its integer value specifies the window style of the application launched. The 1 value will activate and display the window.
The third parameter is optional and its boolean value specifies if it is to wait for the command to complete before further execution. The True value will wait for the completion of the command.
Note that running such scripts properly require to change the client's security settings.
Related threads:
Opening a .exe or .xls file through JS...
How Do I Execute Shelll Commands?
JavaScript FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
How_To_Javascript_Run_Executable_On_Client
How to run an executable program on the client?
Client-side scripts themselves cannot make system calls but on Windows systems you can insert Windows Script Host commands in client-side script.To launch an application on the client machine, place this script in the head of the HTML page.
<script language="javascript" type="text/javascript">
function runApp()
{
var shell = new ActiveXObject("WScript.shell");
shell.run("notepad.exe", 1, True);
}
</script>Place this in the body of the HTML page. The button click will trigger off the function and the application is run.
<input type="button" name="button1" value="Run Notepad" onClick="runApp()" />
var shell = new ActiveXObject("WScript.shell"); Creates the WSH object as a new instance of an ActiveXObject.
shell.run("notepad.exe", 1, True);The run method of WSH starts the executable program.
The first parameter passed into the run method executes the command "notepad.exe".
The second parameter is optional and its integer value specifies the window style of the application launched. The 1 value will activate and display the window.
The third parameter is optional and its boolean value specifies if it is to wait for the command to complete before further execution. The True value will wait for the completion of the command.
Note that running such scripts properly require to change the client's security settings.
Related threads:
Opening a .exe or .xls file through JS...
How Do I Execute Shelll Commands?
JavaScript FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
