I invoke cscript.exe (along with an argument which is the name of a vbs
script) from within a Ruby script (Ruby is sort of an object-orient Perl,
plus more). I capture the return value from cscript.exe and print it.
What I get is a two-line output:
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Is there any way for me to return a string of my choice programmatically
with a .vbs command? I don't see any "return" statement documented for .vbs
Thanks in advance.
--
Regards,
Richard
Question: How does a lawyer sleep at night? He lies on one side, then turns
over and lies on the other!
> Hi All,
>
> I invoke cscript.exe (along with an argument which is the name of a vbs
> script) from within a Ruby script (Ruby is sort of an object-orient Perl,
> plus more). I capture the return value from cscript.exe and print it.
> What I get is a two-line output:
>
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>
> Is there any way for me to return a string of my choice programmatically
> with a .vbs command? I don't see any "return" statement documented for .vbs
Hi
Try this:
Create a .vbs file with the name TestStringReturn.vbs with this content:
Wscript.Echo "This is my returning text to StdOut"
Run it with the following command in a command prompt:
CScript.exe //Nologo TestStringReturn.vbs
If you want to return a numeric errorlevel from a vbscript, you can also do that
(7 in this example):
WScript.Quit 7
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
FYI, here's the code I wrote in Ruby and ran under the SciTE IDE:
require "Win32API"
retval =`cscript.exe Test_StringReturnVal.vbs`
puts "Return value = " + retval
That produced the same result in SciTE's output pane that I received when I
ran the cscript command in a Command window.
Neat stuff.
Regards,
Richard
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3EC40D3C...@hydro.com...
Hi
To avoid those preceding lines, you can use CScript.exe //Nologo