Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - return variable through script in script

Reply
 
Old 09-18-2008   #1 (permalink)
NIDU


 
 

return variable through script in script

I am using the following code to run a script within side a script

Dim WshShell
Set WSHShell =CreateObject("WScript.Shell")
WSHShell.Run"""E:\Rc Wintrans\VBscript\1.vbs"""

1.vbs is a small script that opens a single empty excel file. Now in
1.vbs i have created an object of excel in the following way

set objExcel=createobject("Excel.Application")

this script runs fine and opens an empty excel file. May be alot of
people may think that I can achieve the same by making a sub function
to open an excel file. With which, I can also return the variable
`objExcel` using arguments.
But due to some special reason i want to use `script in script` method
to open an empty excel file. But i dont know how to return the
variable `objexcel` using this method. Can anybody tell me how to
return variable through `script in script`

My System SpecsSystem Spec
Old 09-18-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: return variable through script in script


"NIDU" <nidu50@xxxxxx> wrote in message
news:d0dd359a-8170-47bb-bc85-4f0fc2f47136@xxxxxx
Quote:

>I am using the following code to run a script within side a script
>
> Dim WshShell
> Set WSHShell =CreateObject("WScript.Shell")
> WSHShell.Run"""E:\Rc Wintrans\VBscript\1.vbs"""
>
> 1.vbs is a small script that opens a single empty excel file. Now in
> 1.vbs i have created an object of excel in the following way
>
> set objExcel=createobject("Excel.Application")
>
> this script runs fine and opens an empty excel file. May be alot of
> people may think that I can achieve the same by making a sub function
> to open an excel file. With which, I can also return the variable
> `objExcel` using arguments.
> But due to some special reason i want to use `script in script` method
> to open an empty excel file. But i dont know how to return the
> variable `objexcel` using this method. Can anybody tell me how to
> return variable through `script in script`
The "Run" method spawns a new instance of cscript.exe via the operating
system. Any variables that are passed between your script and this new
instance are passed via the OS. Since Windows knows nothing about objects,
you cannot pass objExcel back to your calling script. By the way, to make
your application robust it would be prudent to invoke the external script
explicitly with "cscript.exe //nologo 1.vbs" instead of relying on
associations that may or may not be present.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: delay script return VB Script
Script switch parameter as variable PowerShell
Script to hide a variable folder VB Script
Obtaining Script Exit Return Codes PowerShell
Current script special variable PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46