Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I pass a variable parameter to WScript.Shell 1

Status
Not open for further replies.

CliveC

Programmer
Nov 21, 2001
1,222
US
I know only enough VBscript to be dangerous.
I am trying to pass a variable parameter from a form
to a program invoked from WScript.Shell.
For the purpose of the example let us suppose that i
am trying to pass a file name to NOTEPAD.
How do I do it? Here is what I have so far:

Code:
<html><head><title>Test</title>
<!--
***************************************************
**** This javascript subroutine is called when   
**** the form's "Certify" button is clicked. It
**** calls the VBscript routine Launch() and then
**** closes the browser window
***************************************************      
-->
<script type="text/javascript">
function process(data) {
  launch(data)
  timer=setTimeout('self.close()',1000) 
}
</script>
<!--
***************************************************
**** launch  
**** This VBscript subroutine will call     
**** program NOTEPAD.EXE
***************************************************   
-->
<script type="text/vbscript">
sub launch(parm1)
Dim MyObj
Set MyObj=CreateObject("WScript.Shell")
MyObj.Run "NOTEPAD.EXE parm1"
end sub
</script>
</head>
<!--
***************************************************
***** This is the HTML for the Cerification form 
***************************************************
-->
<body style="background:beige">
<h2>Master Certification</h2>
ENTER Candidate's Name:<br />
<form name="formC">
<input name="candidate" type="text" size="40" />
<br /><br />
<input type="button" value="Certify" 
 onclick="process(document.formC.candidate.value)" />
</form>
<script type="text/javascript">
document.formC.candidate.focus()
</script>
</body></html>

Any help much appreciated!

Clive
 
>MyObj.Run "NOTEPAD.EXE parm1"
[tt]MyObj.Run "NOTEPAD.EXE " & parm1[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top