469,271 Members | 1,326 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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="ActionRequest1.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 -------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <TITLE>List files and folders for users</TITLE>
  4. </HEAD>
  5.  
  6. <script language="VBScript" type="text/vbscript">
  7.  
  8. Dim wshell
  9. Dim Query
  10. Query = Request.Form("Name")Ď <----- Need the variable from ASP which is where Iím stuck at the moment
  11.  
  12. Set wshell = CreateObject("WScript.shell")
  13. wshell.run "%comspec% /C R: & CD \" & Query & " & Dir /S /T:W /O:D *.txt > c:\Results.txt", 0, True
  14. set wshell = nothing
  15.  
  16. </script>
  17. </BODY>
  18. </HTML>
Oct 6 '07 #1
2 8213
jhardman
3,406 Expert 2GB
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:
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <TITLE>List files and folders for users</TITLE>
  4. </HEAD>
  5. <%Dim wshell
  6. Dim Query
  7. Query = Request.Form("Name")
  8.  
  9. Set wshell = CreateObject("WScript.shell")
  10. wshell.run "%comspec% /C R: & CD \" & Query & " & Dir /S /T:W /O:D *.txt > c:\Results.txt", 0, True
  11. set wshell = nothing %>
  12. </BODY>
  13. </HTML>
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:
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2. <HEAD>
  3. <TITLE>List files and folders for users</TITLE>
  4. </HEAD>
  5. <script language="VBScript" type="text/vbscript">
  6.  
  7. Dim wshell
  8. Dim Query
  9. Query = <%=Request.Form("Name")%>
  10.  
  11. Set wshell = CreateObject("WScript.shell")
  12. wshell.run "%comspec% /C R: & CD \" & Query & " & Dir /S /T:W /O:D *.txt > c:\Results.txt", 0, True
  13. set wshell = nothing 
  14. </script>
  15. </BODY>
  16. </HTML>
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
Oct 8 '07 #2
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
Oct 11 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Graham Mattingley | last post: by
4 posts views Thread by Joey Martin | last post: by
13 posts views Thread by David Morgan | last post: by
1 post views Thread by Don Grover | last post: by
reply views Thread by thomas | last post: by
reply views Thread by tom | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.