I am trying to pass a value (within a url) to a vbscript, that in turn, will use it to launch an executable file (at the client side, this is why im using vbscript) with that value as a parameter for that executable. eg:
the syntax for launching this exe is
\\HQFileServer\Share Launch.exe 1 computername \\ServerName
so im passing the computername as "Name":
http://localhost/launchclient.asp?Name=Laptop1
launchclient.asp
contains:
<script language="vbScript">
set oWshShell = CreateObject("WScript.Shell")
Name = Request.QueryString("Name")
oWshShell.run "\\HQFileServer\Share\Launch.exe " & Name & " \\SCCM2012WAN",1,True
</script>
I tried to debug it, by removing one line at a time, when I realized that, for some reason, it seams that querystring is not passing into the script.. when I omit the Request.QueryString("Name")
and just type in a value - it works...
any ideas why?
I have tried to search for an answer, and cant get this figured out...
Right think I understand what you want to do now after reading this comment .
To pass server-side values to client-side code blocks just use a ASP code block inside the client-side one something like this;
<script language="vbScript">
set oWshShell = CreateObject("WScript.Shell")
oWshShell.run "\\HQFileServer\Share\Launch.exe ""<%= Request.QueryString("Name") %>"" \\SCCM2012WAN",1,True
</script>
This way the ASP engine will replace <%= Request.QueryString("Name") %>
before the code block is sent to the client and will look like this;
<script language="vbScript">
set oWshShell = CreateObject("WScript.Shell")
oWshShell.run "\\HQFileServer\Share\Launch.exe "Laptop1" \\SCCM2012WAN",1,True
</script>
Also mentioned you need it to be seen as a string
value but because VBScript uses quotes ( "
) to denote strings, string within strings have to be escaped, you do this by doubling the quotes ( ""
) .
Old Answer but still relevant-ish
The code is not being processed by Classic ASP because at the moment it is classed as a client-side (HTML) script block being ignored and just passed "as is" in the server response.
There are two ways to remedy this:
Change the script tag so it knows it should be processed by the server by adding the runat="Server"
attribute to the script
tag.
<script language="VBScript" runat="Server"> set oWshShell = CreateObject("WScript.Shell") Name = Request.QueryString("Name") oWshShell.run "\\\\HQFileServer\\Share\\Launch.exe " & Name & " \\\\SCCM2012WAN",1,True </script>
Use an ASP code block.
<% set oWshShell = CreateObject("WScript.Shell") Name = Request.QueryString("Name") oWshShell.run "\\\\HQFileServer\\Share\\Launch.exe " & Name & " \\\\SCCM2012WAN",1,True %>
to avoid confusion with client-side script tags I personally recommend use of the ASP code block syntax ( <% %>
) .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.