Include VBS file in other files?

Author Message
djredmar

  • Total Posts : 64
  • Scores: 0
  • Reward points : 0
  • Joined: 12/11/2006
  • Location: Europe, The Netherlands
  • Status: offline
Include VBS file in other files? Wednesday, April 23, 2008 6:13 PM (permalink)
0
Hi all,

In PHP is it possible to include an file.

example:
<?
inlcude ("settings.php");
?>

Is this possible in any way to use something like in VBscript?

I want to have one file settings.vbs with all of my constants (like path settings) and want to use this file in multiple hta / vbs files.

I searched through the vbscript documentation (script56.chm, script_center.htm & the hey scripting guy!) but can't anything that answers my question.

I can only think of creating registry keys or ini files and have the same function in every hta / vbs file that requests those values.

Help is much appreciated!
blah?
 
#1
    TNO

    • Total Posts : 2094
    • Scores: 36
    • Reward points : 0
    • Joined: 12/18/2004
    • Location: Earth
    • Status: offline
    RE: Include VBS file in other files? Wednesday, April 23, 2008 6:29 PM (permalink)
    5
    if its an hta or html file do this:

    <script type="text/vbscript" src="myFile.vbs"></script>

    if its a vbs do this:

    set oFile = fso.OpenTextFile("myFile,vbs",1)
     sText = oFile.ReadAll
     oFile.close
     ExecuteGlobal sText 


    if its an ASP page, copy the code into a file and rename it ASP also, and do this in the ASP page you are using:

    <!--#include file="myFile.asp"-->
    To iterate is human, to recurse divine. -- L. Peter Deutsch
     
    #2
      djredmar

      • Total Posts : 64
      • Scores: 0
      • Reward points : 0
      • Joined: 12/11/2006
      • Location: Europe, The Netherlands
      • Status: offline
      RE: Include VBS file in other files? Wednesday, April 23, 2008 6:30 PM (permalink)
      0
      Going to try that!

      Thanks alot!
       
      Edit:
      Worked Perfect!
      Thanks alot!
      <message edited by djredmar on Wednesday, April 23, 2008 6:41 PM>
       
      #3
        pman

        • Total Posts : 10
        • Scores: 0
        • Reward points : 0
        • Joined: 7/18/2008
        • Status: offline
        RE: Include VBS file in other files? Sunday, July 20, 2008 10:26 AM (permalink)
        0
        Hi, were you able to get this to work?

        I'm new to VBScript. Created a simple class in a separate vbs file for learning purpose. And now I have another vbs file where I'm testing the class. I need some way to include the vbs class file into this tester file so that I can create a new object in here. Your help is appreciated.
        --
        Regards,

        Pman
        http://www.pmansLab.com/
         
        #4
          tmpalaniselvam

          • Total Posts : 12
          • Scores: 0
          • Reward points : 0
          • Joined: 8/4/2008
          • Status: offline
          RE: Include VBS file in other files? Monday, August 04, 2008 5:30 PM (permalink)
          0
          Hi All,
          I tried the above code.  But this solution is not working for me.  I have given like below..

           Dim gsFile, gsLogFile, gsDirSeparator
           
           'To execute the functions from other script.
            ' Way to execute other VBS files.
               Dim objfso,objfile
               Dim sVBSfile, sAllCode 
               sVBSFile = "D:\VB\Exp2PPT\MyLib.vbs"
               Set objfso = CreateObject("Scripting.FileSystemObject")
               Set objfile=objfso.OpenTextFile(sVBSFile,1)
               'set objfile = objfso.OpenTextFile("D:\VB\Exp2PPT\MyLib,<span class=""high"">vbs</span>",1)
               sAllCode = objfile.ReadAll
               objfile.Close
               'Set objfile = Nothing
               Set objfso = Nothing
               
           'ExecuteGlobal sAllCode
           Execute sAllCode


          I'm calling VBS by cscript. I'm looking for a solution.. Pls see my original post here http://www.visualbasicscript.com/m_63085/mpage_1/key_/tm.htm#63104

          Thanks & Regards,
          Palani.
          http://tips-testing.blogspot.com/index.html
          Quote: Don`t hesitate to initiate!
           
          #5
            ehvbs

            • Total Posts : 3321
            • Scores: 110
            • Reward points : 0
            • Joined: 6/22/2005
            • Location: Germany
            • Status: offline
            RE: Include VBS file in other files? Monday, August 04, 2008 5:47 PM (permalink)
            0
            Hi tmpalaniselvam,

            please explain in detail "is not working for me".

            Regards

            ehvbs
             
            #6
              tmpalaniselvam

              • Total Posts : 12
              • Scores: 0
              • Reward points : 0
              • Joined: 8/4/2008
              • Status: offline
              RE: Include VBS file in other files? Monday, August 04, 2008 8:04 PM (permalink)
              0
              Hi ehvbs,

              I have two VBScripts. One is MyLib.vbs and another one is ExcelOnly.vbs

              ExcelOnly.vbs requires few functions call from MyLib.vbs. I tried ExecuteGlobal and Execute statements. But both are not working. Pls see the code in the prev post.



              Thanks & Regards,
              Palani.
              http://tips-testing.blogspot.com/index.html
              Quote: Don`t hesitate to initiate!
               
              #7
                tmpalaniselvam

                • Total Posts : 12
                • Scores: 0
                • Reward points : 0
                • Joined: 8/4/2008
                • Status: offline
                RE: Include VBS file in other files? Monday, August 04, 2008 10:03 PM (permalink)
                0
                Hi All,

                Earlier I had commented few portion of my code. After enabling commented lines, it is working...The same code with ExecuteGlobal is working fine.


                Thanks & Regards,
                Palani.
                http://tips-testing.blogspot.com/index.html
                Quote: Don`t hesitate to initiate!
                 
                #8
                  TNO

                  • Total Posts : 2094
                  • Scores: 36
                  • Reward points : 0
                  • Joined: 12/18/2004
                  • Location: Earth
                  • Status: offline
                  RE: Include VBS file in other files? Friday, November 21, 2008 2:31 AM (permalink)
                  0
                  Life is alot simpler if you use a wsf file instead of reading a file with fso and executing it. For example:

                   <job id="Parsing">
                        <?job debug="false"?>
                       <script language="JScript" src="e:/lib/JSON.js"/>
                       <script language="JScript" src="e:/lib/String.js"/>
                       <script language="JScript" src="e:/lib/RegList.js"/>
                        <script language="JScript">
                               //Begin the almighty parsing
                        </script>
                   </job>


                  You can mix and match the languages and keep your reusable scripts lying around without  having to make every file humongous. The added benefit is that you can have multiple jobs in the same file and run from the command prompt only the pasrt of the file that you want.
                  To iterate is human, to recurse divine. -- L. Peter Deutsch
                   
                  #9

                    Online Bookmarks Sharing: Share/Bookmark

                    Jump to:

                    Current active users

                    There are 0 members and 1 guests.

                    Icon Legend and Permission

                    • New Messages
                    • No New Messages
                    • Hot Topic w/ New Messages
                    • Hot Topic w/o New Messages
                    • Locked w/ New Messages
                    • Locked w/o New Messages
                    • Read Message
                    • Post New Thread
                    • Reply to message
                    • Post New Poll
                    • Submit Vote
                    • Post reward post
                    • Delete my own posts
                    • Delete my own threads
                    • Rate post

                    2000-2012 ASPPlayground.NET Forum Version 3.9