run VBS files with ASP

D

Dimple

Anyone think of a better way to run a VBS file from in ASP than this
example?

(Goal is to run VBS files that use 'wscript.echo' without having to
re-write to use 'response.write'.)



<script language="vbscript" runat="server">

class wscript_class
function echo(s)
response.write(s & "<br>")
end function
function quit()
' dummy
end function
end class

dim wscript
set wscript = new wscript_class

Include "VBS_FILE_TO_USE_HERE.vbs"

Function Include (Scriptname)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile(Scriptname)
ExecuteGlobal oFile.ReadAll()
oFile.Close
End Function

</script>


VBS file to use as test:

wscript.echo("vbscript using Wscript.Echo")
 
R

Ray Costanzo [MVP]

You could include this class in your code.


Class WScriptEchoer
Public Sub Echo(s)
Response.Write s
End Sub
End Class


Then this would work.
<%
Dim WScript
Set WScript = New WScriptEchoer

WScript.Echo "Hi"
%>

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top