Friday, June 11, 2010

Execute exe files through javascript

Before running the bellow script, you need to midify the setting of the internet explorer
  1.  Open IE
  2. Click Tools -> Internet options
  3. Click security Tab
  4. Select local intranet (Based on your requirement)
  5. Click Custom level button
  6. find "Initialize and script ActiveX controls not marked as safe for scripting"
  7. Click the enable button
  8. Click "Ok"
  9. Click "OK"
  10. Close your browser and re-open to test it
function executeCommands()
{
 var oShell = new ActiveXObject("Shell.Application");
 var commandtoRun = "iexplore.exe";
 oShell.ShellExecute(commandtoRun, "", "", "open", "1");
}