I'm new in this newsgroup and I need your help.
I have script file named test1.vbs. This file is processed by cscript.exe in
NT console. test1.vbs file write some strings into console by WScript.Echo
function and then I need to run another script test2.vbs in same console. I
need to write strings from test2.vbs to same console as test1.vbs.
Is it possible to do it ? I need some comments, script fragments and so on.
Thank you for your help.
Regards
Jiri
P.S. I'm sorry for my English. English is not my native language.
> I have script file named test1.vbs. This file is processed by cscript.exe in
> NT console. test1.vbs file write some strings into console by WScript.Echo
> function and then I need to run another script test2.vbs in same console. I
> need to write strings from test2.vbs to same console as test1.vbs.
3 ways that I know of:
1) Run the two scripts from a common batch file (.bat/.cmd)
2) Load the 2. script into the 1. script at runtime (on the fly) and execute it
with ExecuteGlobal. They can then also share variables, functions etc. The sub
below does this:
Sub Include(sInstFile)
Dim oFSO, f, s
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set f = oFSO.OpenTextFile(sInstFile)
s = f.ReadAll
f.Close
ExecuteGlobal s
End Sub
3) Use a Windows Script Host File (.WSF) file:
<?xml version="1.0" ?>
<package>
<job>
' this will run "file1.vbs"
<script language="VBScript" src="file1.vbs" />
' this will run "file2.vbs"
<script language="VBScript" src="file2.vbs" />
<script language="VBScript">
'
' Some script code here if you want ...
'
' You can use variables, subs and functions
' from the included files.
'
</script>
</job>
</package>
--
torgeir
I think you want streams... so test1 outputs some text and you want it
processed by test2? Here's test1.vbs and test2.vbs:
'test1.vbs
Wscript.Echo "Hello"
'test2.vbs
strText = WScript.StdIn.ReadAll
Wscript.Echo Ucase(strText)
At the command line, execute the following line:
cscript test1.vbs | cscript test2.vbs
The vertical bar 'pipes' the results of test1.vbs into test2.vbs..
test2.vbs reads the results through the Wscript Stdin object. You need
at least WSH 2.0 or later to access streams in WSH.
Regards,
Stein Borge
Author of: Managing Enterprise Systems with the Windows Script Host
Over 800 pages of practicle solutions oriented material, providing
detailed coverage of WSH 5.6, WMI,
ADSI, ADO, CDO, FSO and much more.
s...@nyetspam.enterprisewsh.com
www.EnterpriseWSH.com