WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

How To
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Passing Parameters from Javascript

Keywords: javascript launch shell application java script 

Question:

Just playing around with javascript, html and winbatch on my home computer and I need to pass some info to a wbt file from a javascript I have tried the html code:
a href="filename.wbt param1 param2 param3"
and no parameters are passed. I have also tried:
a href="filename.wbt 'param1 param2 param3'"> 
amongst other combinations with no joy.

Anyone out there got any ideas?

Answer:

I found this somewhere a while ago...I think it will do what you want.

ShellExecute from Javascript

<HTML>
<HEAD>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
  function executeCommands(inputparms)
   {
  // Instantiate the Shell object and invoke its execute method.

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

    var commandtoRun = "Notepad.exe";
    if (inputparms != "")
     {
      var commandParms = document.Form1.filename.value;
     }

 // Invoke the execute method.  
     oShell.ShellExecute(commandtoRun, commandParms,"", "open", "1");
  }
</SCRIPT>


</HEAD>
<BODY>
<FORM name="Form1">
<CENTER>
<BR><BR>
<H1>Execute PC Commands From HTML </H1>
<BR><BR> 
<File Name to Open:> <Input type="text" name="filename"/>
<BR><BR>
<input type="Button" name="Button1" 
   value="Run Notepad.exe" onClick="executeCommands()" />

<input type="Button" name="Button2" 
   value="Run Notepad.exe with Parameters" 
      onClick="executeCommands(' + hasPARMS + ')" />

</CENTER>
</BODY>
</FORM>
</HTML>



Article ID:   W15995
File Created: 2004:04:02:11:20:58
Last Updated: 2004:04:02:11:20:58