473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to send data to a C# App from VBScript

Hello all,

I've been working on an application for a while now and have now come
to a standstill.

I have an application that I intend to have stored on a file server
(developed in C#), which is where the application will be directly ran
from. While running, the application will run a various assortment of
VBScripts (also located on the file server) to which I would like the
vbscripts to be able to pass data back to the currently running
application.

There will never be more than one instance of the application running,
and the scripts will never be ran w/o the application.

I have looked into making the executable a COM Server but then I found
out when publishing public functions form an Executable to COM, only
makes a new object when instantiating it. In other words, in my
VBScript if I can CreateObject() It literally creates a new instance
of the executable. Im trying to pass data to the currently running
instance. I basically want to send status and such from the vbscript
to the running executable. The running executable will be the calling
process to run these scripts.

Does anyone have any ideas on how I can do this?

I'd like to avoid the registry to do this, unless its just a one time
addition to the registry.

Thanks so much in advance for your help!

Feb 19 '07 #1
6 4666


<Sh**********@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
Hello all,

I've been working on an application for a while now and have now come
to a standstill.

I have an application that I intend to have stored on a file server
(developed in C#), which is where the application will be directly ran
from. While running, the application will run a various assortment of
VBScripts (also located on the file server) to which I would like the
vbscripts to be able to pass data back to the currently running
application.

There will never be more than one instance of the application running,
and the scripts will never be ran w/o the application.

I have looked into making the executable a COM Server but then I found
out when publishing public functions form an Executable to COM, only
makes a new object when instantiating it. In other words, in my
VBScript if I can CreateObject() It literally creates a new instance
of the executable. Im trying to pass data to the currently running
instance. I basically want to send status and such from the vbscript
to the running executable. The running executable will be the calling
process to run these scripts.

Does anyone have any ideas on how I can do this?

I'd like to avoid the registry to do this, unless its just a one time
addition to the registry.

Thanks so much in advance for your help!
I would just shell out (using System.Diagnostics.Process) to cscript.exe,
passing it the name of the vbscript file and redirect standard output. Then
in the script use WScript.Echo to write to the output.

Like this:
string scriptName = "foo.vbs";
ProcessStartInfo si = new
ProcessStartInfo("cscript.exe",scriptName);
si.RedirectStandardOutput = true;
si.UseShellExecute = false;

Process p = Process.Start(si);
while (true)
{
string s = p.StandardOutput.ReadLine();
if (s == null)
{
break;
}
Console.WriteLine("VBScript output:" + s);
}
David

Feb 19 '07 #2
<Sh**********@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
Hello all,

I've been working on an application for a while now and have now come
to a standstill.

I have an application that I intend to have stored on a file server
(developed in C#), which is where the application will be directly ran
from. While running, the application will run a various assortment of
VBScripts (also located on the file server) to which I would like the
vbscripts to be able to pass data back to the currently running
application.

There will never be more than one instance of the application running,
and the scripts will never be ran w/o the application.

I have looked into making the executable a COM Server but then I found
out when publishing public functions form an Executable to COM, only
makes a new object when instantiating it. In other words, in my
VBScript if I can CreateObject() It literally creates a new instance
of the executable. Im trying to pass data to the currently running
instance. I basically want to send status and such from the vbscript
to the running executable. The running executable will be the calling
process to run these scripts.

Does anyone have any ideas on how I can do this?

I'd like to avoid the registry to do this, unless its just a one time
addition to the registry.

Thanks so much in advance for your help!

Both C# and your VBScript run in separate processes, that means that you'll have to start
the script from C# using System.Diagnostics.Process, all you can do to "communicate back" to
the parent process is by redirecting the standard output of the scripting engine.
This is quite limiting, all you can do is send text back using WScript.Echo, but maybe it
suits your needs.

Willy.
Feb 19 '07 #3
On Feb 19, 5:08 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
<ShieldsJa...@gmail.comwrote in message

news:11**********************@a75g2000cwd.googlegr oups.com...


Hello all,
I've been working on an application for a while now and have now come
to a standstill.
I have an application that I intend to have stored on a file server
(developed in C#), which is where the application will be directly ran
from. While running, the application will run a various assortment of
VBScripts (also located on the file server) to which I would like the
vbscripts to be able to pass data back to the currently running
application.
There will never be more than one instance of the application running,
and the scripts will never be ran w/o the application.
I have looked into making the executable a COM Server but then I found
out when publishing public functions form an Executable to COM, only
makes a new object when instantiating it. In other words, in my
VBScript if I can CreateObject() It literally creates a new instance
of the executable. Im trying to pass data to the currently running
instance. I basically want to send status and such from the vbscript
to the running executable. The running executable will be the calling
process to run these scripts.
Does anyone have any ideas on how I can do this?
I'd like to avoid the registry to do this, unless its just a one time
addition to the registry.
Thanks so much in advance for your help!

Both C# and your VBScript run in separate processes, that means that you'll have to start
the script from C# using System.Diagnostics.Process, all you can do to "communicate back" to
the parent process is by redirecting the standard output of the scripting engine.
This is quite limiting, all you can do is send text back using WScript.Echo, but maybe it
suits your needs.

Willy.- Hide quoted text -

- Show quoted text -
Im familar w/ wscript.echo, but my goal is to have the output
displayed within the gui I am creating. I basically want to create a
library vb script function foo(string) that passes the string to the
external application....

I am aware of how to call the vbscripts....

Feb 20 '07 #4


<Sh**********@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
On Feb 19, 5:08 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
><ShieldsJa...@gmail.comwrote in message

news:11**********************@a75g2000cwd.googleg roups.com...


Hello all,
I've been working on an application for a while now and have now come
to a standstill.
I have an application that I intend to have stored on a file server
(developed in C#), which is where the application will be directly ran
from. While running, the application will run a various assortment of
VBScripts (also located on the file server) to which I would like the
vbscripts to be able to pass data back to the currently running
application.
There will never be more than one instance of the application running,
and the scripts will never be ran w/o the application.
I have looked into making the executable a COM Server but then I found
out when publishing public functions form an Executable to COM, only
makes a new object when instantiating it. In other words, in my
VBScript if I can CreateObject() It literally creates a new instance
of the executable. Im trying to pass data to the currently running
instance. I basically want to send status and such from the vbscript
to the running executable. The running executable will be the calling
process to run these scripts.
Does anyone have any ideas on how I can do this?
I'd like to avoid the registry to do this, unless its just a one time
addition to the registry.
Thanks so much in advance for your help!

Both C# and your VBScript run in separate processes, that means that
you'll have to start
the script from C# using System.Diagnostics.Process, all you can do to
"communicate back" to
the parent process is by redirecting the standard output of the scripting
engine.
This is quite limiting, all you can do is send text back using
WScript.Echo, but maybe it
suits your needs.

Willy.- Hide quoted text -

- Show quoted text -

Im familar w/ wscript.echo, but my goal is to have the output
displayed within the gui I am creating. I basically want to create a
library vb script function foo(string) that passes the string to the
external application....
If you use CScript for your script host then

sub foo(string)
Wscript.Echo(string)
end sub

will write the string to the process's standard output. When you spawn a
process from C#, you can redirect the child process's standard output and
read it from C#.

David

Feb 20 '07 #5
On Feb 20, 9:35 am, "David Browne" <davidbaxterbrowne no potted
m...@hotmail.comwrote:
<ShieldsJa...@gmail.comwrote in message

news:11**********************@m58g2000cwm.googlegr oups.com...


On Feb 19, 5:08 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
<ShieldsJa...@gmail.comwrote in message
>news:11**********************@a75g2000cwd.googleg roups.com...
Hello all,
I've been working on an application for a while now and have now come
to a standstill.
I have an application that I intend to have stored on a file server
(developed in C#), which is where the application will be directly ran
from. While running, the application will run a various assortment of
VBScripts (also located on the file server) to which I would like the
vbscripts to be able to pass data back to the currently running
application.
There will never be more than one instance of the application running,
and the scripts will never be ran w/o the application.
I have looked into making the executable a COM Server but then I found
out when publishing public functions form an Executable to COM, only
makes a new object when instantiating it. In other words, in my
VBScript if I can CreateObject() It literally creates a new instance
of the executable. Im trying to pass data to the currently running
instance. I basically want to send status and such from the vbscript
to the running executable. The running executable will be the calling
process to run these scripts.
Does anyone have any ideas on how I can do this?
I'd like to avoid the registry to do this, unless its just a one time
addition to the registry.
Thanks so much in advance for your help!
Both C# and your VBScript run in separate processes, that means that
you'll have to start
the script from C# using System.Diagnostics.Process, all you can do to
"communicate back" to
the parent process is by redirecting the standard output of the scripting
engine.
This is quite limiting, all you can do is send text back using
WScript.Echo, but maybe it
suits your needs.
Willy.- Hide quoted text -
- Show quoted text -
Im familar w/ wscript.echo, but my goal is to have the output
displayed within the gui I am creating. I basically want to create a
library vb script function foo(string) that passes the string to the
external application....

If you use CScript for your script host then

sub foo(string)
Wscript.Echo(string)
end sub

will write the string to the process's standard output. When you spawn a
process from C#, you can redirect the child process's standard output and
read it from C#.

David- Hide quoted text -

- Show quoted text -
Oh really??

How would I go about redirecting the output so that I can read it in
C#?

That sounds perfect!

Feb 20 '07 #6
On Feb 20, 9:35 am, "David Browne" <davidbaxterbrowne no potted
m...@hotmail.comwrote:
<ShieldsJa...@gmail.comwrote in message

news:11**********************@m58g2000cwm.googlegr oups.com...


On Feb 19, 5:08 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.bewrote:
<ShieldsJa...@gmail.comwrote in message
>news:11**********************@a75g2000cwd.googleg roups.com...
Hello all,
I've been working on an application for a while now and have now come
to a standstill.
I have an application that I intend to have stored on a file server
(developed in C#), which is where the application will be directly ran
from. While running, the application will run a various assortment of
VBScripts (also located on the file server) to which I would like the
vbscripts to be able to pass data back to the currently running
application.
There will never be more than one instance of the application running,
and the scripts will never be ran w/o the application.
I have looked into making the executable a COM Server but then I found
out when publishing public functions form an Executable to COM, only
makes a new object when instantiating it. In other words, in my
VBScript if I can CreateObject() It literally creates a new instance
of the executable. Im trying to pass data to the currently running
instance. I basically want to send status and such from the vbscript
to the running executable. The running executable will be the calling
process to run these scripts.
Does anyone have any ideas on how I can do this?
I'd like to avoid the registry to do this, unless its just a one time
addition to the registry.
Thanks so much in advance for your help!
Both C# and your VBScript run in separate processes, that means that
you'll have to start
the script from C# using System.Diagnostics.Process, all you can do to
"communicate back" to
the parent process is by redirecting the standard output of the scripting
engine.
This is quite limiting, all you can do is send text back using
WScript.Echo, but maybe it
suits your needs.
Willy.- Hide quoted text -
- Show quoted text -
Im familar w/ wscript.echo, but my goal is to have the output
displayed within the gui I am creating. I basically want to create a
library vb script function foo(string) that passes the string to the
external application....

If you use CScript for your script host then

sub foo(string)
Wscript.Echo(string)
end sub

will write the string to the process's standard output. When you spawn a
process from C#, you can redirect the child process's standard output and
read it from C#.

David- Hide quoted text -

- Show quoted text -
NM, I found it! Yall are awesome and this is so much easier!!!

Thanks!!!

Feb 20 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: NewbieJon | last post by:
I am attempting to send the variable "sComputerName" from my ActiveX script to "GetInfo.asp" using javascript. (Having been advised this is the way to get my ActiveX variable into my ASP script) ...
3
by: Kassam | last post by:
Hi MVPs out there. I have constructed an order form and the users will enter the informtion. I now need to send the filled out form as an e-mail (body being the HTML with the fille din data) to...
1
by: SABmore | last post by:
I have the following code that populates 3 independent drop-down boxes with data from arrays. From there the user can select a value from a drop-down list, or input data into a text box. The user...
6
by: leo | last post by:
Hello there Im having trouble in storing blank or space value on a variable wich data type is Date/Time, if i make a statement like this Field Data Type...
9
by: Peter | last post by:
I have created a small windows app that gathers some user entered data, then prints it to a designated printer. A specific person then collects the prints from the printer and processes the info...
2
by: zeg37 | last post by:
Hi, I am working with a Microsoft Data Page where the records are filtered by two dates the user selects prior to any records being loaded. After selecting dates they click on a button (BtnGo)...
4
by: Thomas Eichner | last post by:
Hi, does anybody know a public website which offers a service that displays all data send by a browser (or an app calling the website), especially HTTP GET and POST data, browser data etc.? I...
0
by: joeyjoejnr | last post by:
hi, i've got a database in ms access. using ASP (vbscript) and IIS. I can send text e-mails through ASP but i want to attach a file from the database to the e-mail when it is sent. can anyone...
1
by: GhOsTTeCh | last post by:
Hello, firstly i appologize if i posted in the wrong section seeing as my script is for VBscript. How do i send a few bytes of data to an internal server. I have an application that monitors...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.