Post ASP results to VBScript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moodyman13
    New Member
    • Sep 2007
    • 6

    Post ASP results to VBScript

    Hi All,

    I’m in a bit of pickle with ASP and VBscript variable and hope someone could get me some advice.

    There’s a FORM’ I’ve created in ASP and its purpose is to capture the name(s) of users. The plan is then to pass the information from ASP to VBScript. My dilemma is how to extract the information in ASP and use it in VBScript. (Please see code below)

    I’ve read in some forums that is simply can’t be done. Unfortunately, I can’t run what I need in any other form except in VBscript

    There was one suggestion though to create a .vbs file and pass the ASP variable as an argument. But not having much experience with VBScript, I’m not 100% percent sure how that is done.

    Thanks in advance for all the help.

    Regards
    [html]<HTML>
    <BODY>
    <Table>

    <TR height="20" style="height: 15.0pt">
    <TD colspan="8" align=Left>
    <img border="0" src="R:\Pic.bmp " width="150" height="150">
    </TD>
    </TR>

    <TR>
    <TD>
    <FORM method="POST" action="ActionR equest1.asp">

    <br>
    Customer :
    <br>
    <select multiple name="Name" Size="3">
    <option value =" John " selected> John </option>
    <option value =" Jane "> Jane </option>
    <option value =" Cory "> Cory </option>
    </select>
    <br>
    <br>

    <INPUT type="submit" value="Submit">
    </FORM>
    </TD>
    </TR>

    </Table>
    </BODY>
    </HTML>
    [/html]
    '------------- VBSCRIPT -------------------------------------
    [code=asp]
    <HTML>
    <HEAD>
    <TITLE>List files and folders for users</TITLE>
    </HEAD>

    <script language="VBScr ipt" type="text/vbscript">

    Dim wshell
    Dim Query
    Query = Request.Form("N ame")‘ <----- Need the variable from ASP which is where I’m stuck at the moment

    Set wshell = CreateObject("W Script.shell")
    wshell.run "%comspec% /C R: & CD \" & Query & " & Dir /S /T:W /O:D *.txt > c:\Results.txt" , 0, True
    set wshell = nothing

    </script>
    </BODY>
    </HTML>[/code]
    Last edited by jhardman; Oct 8 '07, 06:42 PM. Reason: put code in code tags. please use code tags in the future, notice the button marked --#--
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    I'm not sure I understand you, I tend to use the terms "ASP" and "VBScript" interchangeably . ASP is usually written with a scripting language such as VBScript, most people don't use VBScript for anything else. Are you trying to use VBScript on the client-side (a script that runs on the user's browser) or on the server-side (a script that the server reads and executes before it is sent to the final web page)? If the former is the case (the way most people use VBScript), then I would write it like this:
    [code=asp]
    <HTML>
    <HEAD>
    <TITLE>List files and folders for users</TITLE>
    </HEAD>
    <%Dim wshell
    Dim Query
    Query = Request.Form("N ame")

    Set wshell = CreateObject("W Script.shell")
    wshell.run "%comspec% /C R: & CD \" & Query & " & Dir /S /T:W /O:D *.txt > c:\Results.txt" , 0, True
    set wshell = nothing %>
    </BODY>
    </HTML>[/code] Otherwise I might warn you that only the internet explorer browser (which is no longer the most-used browser) ever supported client-side VBScript. But if you did want it to look like that, try this: [code=asp]<HTML>
    <HEAD>
    <TITLE>List files and folders for users</TITLE>
    </HEAD>
    <script language="VBScr ipt" type="text/vbscript">

    Dim wshell
    Dim Query
    Query = <%=Request.Form ("Name")%>

    Set wshell = CreateObject("W Script.shell")
    wshell.run "%comspec% /C R: & CD \" & Query & " & Dir /S /T:W /O:D *.txt > c:\Results.txt" , 0, True
    set wshell = nothing
    </script>
    </BODY>
    </HTML>[/code] This will still need to be saved as .ASP for the server to insert the text in the appropriate place. I do not know whether there is a way to access posted data through purely client-side scripts. Perhaps if the data is sent through the querystring... but I'm not an expert on client-side anything. Let me know if this helps.

    Jared

    Comment

    • moodyman13
      New Member
      • Sep 2007
      • 6

      #3
      Thanks Jared. I will give it a try. The other option I was considering was to store the results into a Database before running SQL query for the Shell script.

      Thanks once again for your help

      Regards

      Comment

      Working...