473,408 Members | 1,730 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,408 software developers and data experts.

VBScripts

I am trying to run/execute a .vbs file from c# as a process. Is this
possible? If so, how.

TIA

Jim
Jul 10 '07 #1
4 1768
Jim,

Yes, you can just use the Process class and pass the path to the script
and it should execute it.

You might want to consider translating the script into C#, as it might
make maintaining the code easier.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jim Rasmussen" <jr********@idealas.comwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
>I am trying to run/execute a .vbs file from c# as a process. Is this
possible? If so, how.

TIA

Jim
Jul 10 '07 #2
Nicholas,
Thanks for the quick reply. here is what I have....

ProcessStartInfo psi = new ProcessStartInfo(Server.MapPath("render.vbs"));
psi.UseShellExecute = false;
psi.Arguments = ExamID.ToString() + " compexam.xsl";
Process.Start(psi);

when stepping thru the previous code, an error is encountered that states
"The specified executable is not a valid Win32 application"

and when this code is executed, all that happens is a beep. The code in
render.vbs is ...
Option Explicit
MsgBox("hello world") //this is just to test the execution of the
vbs file
using (Process oProc = new Process())

{

oProc.StartInfo.FileName = Server.MapPath("render.vbs");

oProc.StartInfo.Arguments = ExamID.ToString() + " compexam.xsl";

oProc.Start();

oProc.WaitForExit(10000);

}

Thanks for you input,

Jim

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:03**********************************@microsof t.com...
Jim,

Yes, you can just use the Process class and pass the path to the script
and it should execute it.

You might want to consider translating the script into C#, as it might
make maintaining the code easier.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jim Rasmussen" <jr********@idealas.comwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
>>I am trying to run/execute a .vbs file from c# as a process. Is this
possible? If so, how.

TIA

Jim

Jul 10 '07 #3
Well I changed
psi.UseShellExecute = false;
to
psi.UseShellExecute = true;

no error just the system beep.

Thanks
Jim

"Jim Rasmussen" <jr********@idealas.comwrote in message
news:ug**************@TK2MSFTNGP04.phx.gbl...
Nicholas,
Thanks for the quick reply. here is what I have....

ProcessStartInfo psi = new ProcessStartInfo(Server.MapPath("render.vbs"));
psi.UseShellExecute = false;
psi.Arguments = ExamID.ToString() + " compexam.xsl";
Process.Start(psi);

when stepping thru the previous code, an error is encountered that states
"The specified executable is not a valid Win32 application"

and when this code is executed, all that happens is a beep. The code in
render.vbs is ...
Option Explicit
MsgBox("hello world") //this is just to test the execution of the
vbs file
using (Process oProc = new Process())

{

oProc.StartInfo.FileName = Server.MapPath("render.vbs");

oProc.StartInfo.Arguments = ExamID.ToString() + " compexam.xsl";

oProc.Start();

oProc.WaitForExit(10000);

}

Thanks for you input,

Jim

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:03**********************************@microsof t.com...
>Jim,

Yes, you can just use the Process class and pass the path to the
script and it should execute it.

You might want to consider translating the script into C#, as it might
make maintaining the code easier.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jim Rasmussen" <jr********@idealas.comwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
>>>I am trying to run/execute a .vbs file from c# as a process. Is this
possible? If so, how.

TIA

Jim


Jul 10 '07 #4
On Tue, 10 Jul 2007 12:46:36 -0500, "Jim Rasmussen"
<jr********@idealas.comwrote:
>I am trying to run/execute a .vbs file from c# as a process. Is this
possible? If so, how.

TIA

Jim
First of all before you try anything be sure to check your anti-virus
software's functionality. Symantec for instance will silently kill any
attempts to run scripts in this way

--
http://bytes.thinkersroom.com
Jul 11 '07 #5

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

Similar topics

0
by: warren ali | last post by:
Hi all! I'm new to python and I seem to have a hit a of a brick wall. I hope you guys can help. I'm trying to rewrite some of my vbscripts in python. This particular script connects to a...
24
by: Kanthi Kiran Narisetti | last post by:
Hi All, I am Windows Systems Administrator(planning to migrate to Linux administration in near future), I have occassionally written few batch files and Vbscripts to automate my tasks. Now I...
0
by: Melissa | last post by:
Hi, One of my web controls in a .NET project trys to call functions in a VBScript file (*..vbs) and JScript file (*.js) . But I can not make the connection by having "Imports". Can someone help...
6
by: ShieldsJared | last post by:
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...
1
LMHelper
by: LMHelper | last post by:
I am in the process of switching an Access Database that was originally designed in Access 97 and they need it to switch over to Access 2000-2003 Database Version. We have run into errors when...
12
LMHelper
by: LMHelper | last post by:
I am in the process of switching an Access Database that was originally designed in Access 97 and they need it to switch over to Access 2000-2003 Database Version. We have run into errors when moving...
1
by: Airtech | last post by:
I am developing a database in Access 2002/2003 for use in Configuration Management. The application has reach the point where users of my application need to execute scripts in various formats. I...
0
by: xiang | last post by:
I wanted to mask password using inputbox but how come when i enter the code to mask the password in vbscript, its show me error on 'Object required'.
4
by: willywonka | last post by:
Hi, I am new to .net and hardly know anything therefore i have an extremely basic question. when i am running any vb script using a project i created in .net i am simply entering my file name...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.