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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML variables 1

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
I am new to HTML and I would like to launch a batch file on a machine where this web page will reside. I would like to created checkboxed for all the different batch files and once you check one of the boxes, it assignes the file name to the vbscript file name. So when you hit process, it knows which batch to run. here is the script i would be using

Need variable to be assigned to the "myBatFile.bat" part of the vbscript.

<%@ LANGUAGE="VBSCRIPT" %>
<%
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run ("c:\myBatfile.bat")
%>

<html>
<title>Sample</title>
<body>
Blah Blah
</body>
</html>
 
Or PHP forum or Perl forum or cgi foum or....

HTML cannot execute, period. You'll need a scripting language, check to see what languages your host supports and chose one of them. I prefer PHP to ASP, as PHP is FOSS and ASP is M$.

[plug=shameless]
[/plug]
 
I would try something like this:
Code:
[COLOR=blue][b]<script language="vbscript" type="text/vbscript">
<!--
  Sub Button1_onclick()
    With CreateObject("Wscript.Shell")
      For Each i In document.body.getElementsByTagName("input")
        If i.type = "checkbox" Then
          if i.checked Then
            .Run i.dataFld
            i.checked = False
          End If  
        End If
      Next  
    End With
  End Sub
// -->
</script>[/b][/color]
<html>
<body>
  [b]<input id="chk1" datafld="c:\test1.bat" type="checkbox" />&nbsp;Test1<br />
  <input id="chk2" datafld="c:\test2.bat" type="checkbox" />&nbsp;Test2<br />
  <input id="chk3" datafld="c:\test3.bat" type="checkbox" />&nbsp;Test3<br />
  <input id="chk4" datafld="c:\test4.bat" type="checkbox" />&nbsp;Test4<br />
  <input id="chk5" datafld="c:\test5.bat" type="checkbox" />&nbsp;Test5<br />
  <input id="Button1" type="button" value="Run Batch Files" onclick="Button1_onclick" />[/b]
</body>
</html>

I get a warning about the active-x control, but it works...

*Note that it unchecks the box after it executes, this is to prevent executing it twice (as it was doing)...

In the future, these questions should be posted in the VBScript or HTML areas...

Hope This Helps ;-)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
>> In the future, these questions should be posted in the VBScript or HTML areas...

Ooops... I thought I was in the VB forum (whoops)
[hammer]

Sorry!!!!!

Ask Away ;-)

Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top