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)
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!
|
|
|
|
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)
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
|
|
|
|
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)
Going to try that! Thanks alot! Edit: Worked Perfect! Thanks alot!
<message edited by djredmar on Wednesday, April 23, 2008 6:41 PM>
|
|
|
|
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)
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.
|
|
|
|
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)
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
|
|
|
|
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)
Hi tmpalaniselvam, please explain in detail "is not working for me". Regards ehvbs
|
|
|
|
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)
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.
|
|
|
|
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)
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.
|
|
|
|
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)
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
|
|
|
|