Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to pass argument to VBScript NOT via WScript

9 views
Skip to first unread message

CW

unread,
Dec 10, 2009, 5:14:00 AM12/10/09
to
Hi All,

I need to create a VBScript to run in a 3rd-party application which
does not support WScript.
Most of the ways in internet pass argument to VBScript via WScript.
Is there any other way to do so?

Thanks and Regards,
Cherry

Richard Mueller [MVP]

unread,
Dec 10, 2009, 9:52:52 AM12/10/09
to

"CW" <cherr...@gmail.com> wrote in message
news:0564083f-3c64-453f...@a39g2000pre.googlegroups.com...

I don't know of any method that does not use the Wscript object. Another
thought is to use a class, with Property Let and Property Get methods, but I
don't believe you can assign values from outside the script. You may be out
of luck.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


mr_unreliable

unread,
Dec 10, 2009, 12:52:18 PM12/10/09
to
CW wrote:
> I need to create a VBScript to run in a 3rd-party application which
> does not support WScript.
> Most of the ways in internet pass argument to VBScript via WScript.
> Is there any other way to do so?
>

hi Cherry,

It would be helpful if you gave us a little more detail
about how you are running the vbscript.

For example, are you using a "Microsoft Script Control"
to run the script, or maybe you are using the (shudder)
IActiveScript interface?

Since the application is 3rd-party, then maybe you don't
have the source code, which would make it even more
complicated...

If either the script control or the (shudder) IActiveScript
interface is being used, then I may be able to help.

If it is somebody else's code and you don't have the
source (a "black box") then the only way may be something
a responsible scripter wouldn't consider (like using the
system api).

cheers, jw

mr_unreliable

unread,
Dec 10, 2009, 1:22:05 PM12/10/09
to
If you wish to pass some argument to a vbscript without
the benefit of WScript, then there are a number of
"Brute Force" options.

For example, you could run the 3re-party app from a
bat file or a vbs wrapper, place your args somewhere
the script can find them and use a non-WScript method
to get the args.

The most primitive method is to write the args into
a file, then use fso to read the file and retrieve
the args.

Also, you might use system parameters. You could
use the wshShell.Environment to retrieve the parameter.

Finally, you could use the Registry. Set up a CherrySoftware
key, and put your arguments in subkeys. Then read
them back using wshShell.regread method.

cheers, jw

Al Dunbar

unread,
Dec 10, 2009, 10:50:35 PM12/10/09
to
If one of yourselves is ahead of yourself, then the other must be behind.

LOL, I am beside myself with laughter! ;-)

/Al

"mr_unreliable" <kindlyReply...@notmail.com> wrote in message
news:eEL6EUce...@TK2MSFTNGP05.phx.gbl...

CW

unread,
Dec 11, 2009, 5:29:40 AM12/11/09
to
Thanks all~.
The 3rd-party application is BusinessObjects (BOJ).
It allows to upload script/exe and schedule programs within
BusinessObjects.
In the schedule setup, there is a argument field and in fact, this
value is various for different schedules.
So, it is not possible to save the argument somewhere out of the
application.

I tried to schedule a bat file instead but seems it is another big
problem for the bat file to call a VB script with/within the
application.

So, I am thinking of simply write a VB.Net exe and read the argument.
This should be more flexible and feasible.

Or, if any one of you has similar experience of BOJ + VBScript can
share your solution...


Best Regards,
Cherry

On 12月11日, 上午2時22分, mr_unreliable <kindlyReplyToNewsgr...@notmail.com>
wrote:

Csaba Gabor

unread,
Dec 16, 2009, 12:49:47 AM12/16/09
to
On Dec 11, 2:29 am, CW <cherrywa...@gmail.com> wrote:
> Thanks all~.
> The 3rd-party application is BusinessObjects (BOJ).
> It allows to upload script/exe and schedule programs within
> BusinessObjects.
> In the schedule setup, there is a argument field and in fact, this
> value is various for different schedules.
> So, it is not possible to save the argument somewhere out of the
> application.
>
> I tried to schedule a bat file instead but seems it is another big
> problem for the bat file to call a VB script with/within the
> application.
>
> So, I am thinking of simply write a VB.Net exe and read the argument.
> This should be more flexible and feasible.
>
> Or, if any one of you has similar experience of BOJ + VBScript can
> share your solution...
>
> Best Regards,
> Cherry

I've no experience with BOJ. However, one
possibility for you is to create an instance of IE
and then affix a value to that. You must then
locate the instance within your called script.
HOWEVER, this solution will only work on a
single instance basis:

Loop through
CreateObject("Shell.Application").Windows
to check all IEs for
ie.document.parentWindow.myApp
(and if you encounter any errors just continue
looping).

If you have found such an IE, then stuff it
with the argument you wish to pass.
Otherwise, bring up a new instance of IE with
Set ie=CreateObject("InternetExplorer.Application")
ie.Navigate2 "about:blank" 'Give it a dom
ie.Visible = true 'debugging
ie.document.parentWindow.execScript( _
"window.myApp=null")
'And now:
ie.document.parentWindow.myApp = "args go here"
'Now dispatch to your script

The biggest caveat with this method is that if your
script has to create IE, then it should really dispatch
to itself in the background and then keep looping in
order to keep IE alive. You will encounter this issue
once you comment out ie.Visible=true

Csaba Gabor from Vancouver

0 new messages