Call VBScript From .NET

J

Jordan S.

I have a VBScript that runs on the server. I want to call that script from
an ASP.NET Web application. How can I do that?

Thanks!
 
K

Kevin Spencer

System.Diagnostics.Process.Start("script.vb");

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Accept the Unexpected.
 
J

Juan T. Llibre

Maybe you meant :

System.Diagnostics.Process.Start("script.vbs");

But, it's not really running vbs under ASP.NET, is it ?
It runs it as a different process.
 
M

Michael Nemtsev

Hello Juan,

That example demonstrate approach that OP may undertake

JL> Is that example running a VBscript under ASP.NET ?
JL>
JL> Juan T. Llibre, asp.net MVP
JL> aspnetfaq.com : http://www.aspnetfaq.com/
JL> asp.net faq : http://asp.net.do/faq/
JL> foros de asp.net, en español : http://asp.net.do/foros/
JL> ===================================
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
J

Jordan S.

RE:

<< You can't. VBscript doesn't run on ASP.NET. >>

What about via COM Interop? Or ???

I can modify the VB script to write a string to a file, then read that file
from the ASP.NET app - but I'd prefer to NOT do it that way. I understand
that VBScript can't be called from .NET as any COM components cannot -
unless COM Interop is brought into the picture. So is COM interop something
that could be used to call a VBScript - or is there some other or easier
way?

Thanks!
 
J

Juan T. Llibre

You can run it via WSH...but that's not really "running under ASP.NET".
That's shelling out and running another process.
 
K

Kevin Spencer

Hi Juan,

Yes, "vbs" is correct - I almost never use VBScripts these days.

As for whether it's "really" running under ASP.Net, that was not specified.
That is, whether or not any communication between the script and the ASP.Net
app is necessary. In a case where information such as that is not specified,
I will provide the simplest possible solution, and leave it to the OP to
qualify the issue if necessary. One of my rules of thumb is, avoid
complexity unless it is necessary, and then keep it to a minimum. In this
case, it didn't sound like there needed to be any interaction between the
app and the script. But if so, the OP can point that out.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Accept the Unexpected.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

In short no.

But I think you should give us more details about what you want and what you
have.
 
J

Jordan S.

RE:
<< But I think you should give us more details about what you want and what
you have. >>

One of my network engineering friends has a VBS script that uses WMI to
determine [which user is connected to a remote machine]. He wants to be able
to run that script and display returned information (user info from remote
machine) via an ASP.NET Web application [page]. While I am familiar with
ASP.NET, I have never attempted to have my ASP.NET Web applications interact
with or use VBScript. My friend said he already has the VBScript ready to
go - so I thought that if there was an easy way to somehow call it and get
its return data into the ASP.NET app, then we might want to go that route.
Same process (direct communication) would be nice - but I could always pipe
the script results to a text file, then read that (but that's rather ugly,
IMO).

Maybe it would be better to translate the WMI logic in the script into
native .NET (perhaps using someting in System.DirectoryServices) and omit
the VBScript altogether.

Any feedback is appreciated.

-Thanks
 
J

Juan T. Llibre

re:
It is possible to have the "same" WMI script in C#.

Good point.
Of course, the very same System.Management objects can be accessed with VB.NET, too.




Jurgen_O said:
Hi Jordan,

It is possible to have the "same" WMI script in C#.

Take a look at Classes in the System.Management namespace.
and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/using_wmi.asp

HTH.

J.O.

Jordan S. said:
RE:
<< But I think you should give us more details about what you want and what
you have. >>

One of my network engineering friends has a VBS script that uses WMI to
determine [which user is connected to a remote machine]. He wants to be able
to run that script and display returned information (user info from remote
machine) via an ASP.NET Web application [page]. While I am familiar with
ASP.NET, I have never attempted to have my ASP.NET Web applications interact
with or use VBScript. My friend said he already has the VBScript ready to
go - so I thought that if there was an easy way to somehow call it and get
its return data into the ASP.NET app, then we might want to go that route.
Same process (direct communication) would be nice - but I could always pipe
the script results to a text file, then read that (but that's rather ugly,
IMO).

Maybe it would be better to translate the WMI logic in the script into
native .NET (perhaps using someting in System.DirectoryServices) and omit
the VBScript altogether.

Any feedback is appreciated.

-Thanks
 
K

Kevin Spencer

See the System.Management and System.Management.Instrumentation namespaces.
Chances are, it would be fairly easy to port his VBScript to a part of your
..Net app.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top