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

Including VBS in ASP and WSF

Status
Not open for further replies.

An0Ant

MIS
Oct 10, 2003
6
US
Hi,

How can one include a VBS file in ASP page and WSF code?

I have some functions in an asp page "ServerFunctions.asp"
that I want to use in WSF file. I created ServerFunctions.vbs removing &quot;<%&quot; and &quot;%>

This file I can use in WSF file with script tag.
In ASP I tried script tag as
<script runat=&quot;SERVER&quot; Language=&quot;VBScript&quot; src=&quot;...&quot;/>
but variables declared in the VBS file are not available.

TIA
 
Have you tried this syntax ?
Code:
<!--#include virtual=&quot;...&quot;-->

Hope This Help
PH.
 
It's not about location of the file.

Below is an example of WSF file.

=========
<job id=&quot;TestJob&quot;>
<?job debug=&quot;true&quot;?>
<script Language=&quot;VBScript&quot; src=&quot;ServerFunctions.asp&quot;/>
<script language=&quot;VBScript&quot;>
' Main Program
msgbox &quot;Hi&quot;
WScript.Quit
</script>
</job>
=============

The file ServerFunctions.asp obviously includes &quot;<%&quot; and &quot;%>&quot; tags. So the WSH complians with this error.
testi.wsf(1, 2) Microsoft VBScript compilation error: Expec
ed statement

(Also it's not about file extension. I tried file with ASP extension but without <% and %> tags w/o any problems.

On the other hand, if I remove <% and %> and tried to include the file in an ASP page with <script runat=....>
then functions/variables declared in the file are not available in page including this.
 
Have you tried this in your asp page ?
Code:
<!--#include virtual=&quot;BeginScript.asp&quot;-->
<!--#include virtual=&quot;ServerFunctions.asp&quot;--> 
<!--#include virtual=&quot;EndOfScript.asp&quot;-->
With BeginScript.asp containing
Code:
<%
and EndOfScript.asp containing
Code:
 %>

Hope This Help
PH.
 
Thanks for quick reply.

Seemed like nice work-around until I got following:

========================
Active Server Pages error 'ASP 0116'

Missing close of script delimiter

/eRepLoad/BeginScript.inc, line 1

The Script block lacks the close of script tag (%>).
========================

Is it something to do with properties of the virtual app or IIS?

 
And what about this:
Code:
<%
Set FSO=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set OTF=FSO.OpenTextFile(Server.MapPath(&quot;/eRepLoad/SerververFunctions.asp&quot;),1)
prog=OTF.ReadAll
OTF.Close
Set OTF=Nothing
Set FSO=Nothing
ExecuteGlobal prog
%>


Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top