Run vbscript on serverside using asp.net

Go To StackoverFlow.com

3

sorry in advance for any orthographic mistakes (english is not my first language).

I want to run a .vbs file on the server side using a button in an asp.net application (that is, from the client side). The vbs file could contain something as simple as a msgBox("Hello World!") and it's located in the server where the page is hosted, moreover, it's in the same folder as the .aspx file.

I've tried to use this code in the Button_Click event:

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.WorkingDirectory = Request.MapPath("~/");
process.StartInfo.FileName = Request.MapPath("displayHelloWorldOnTheServer.vbs");
process.Start();

but the script doesn't seem to be running.

Any suggestions?

2012-04-04 18:31
by Rojas Azules
Can you explain in more accurate detail, what it is that you want to accomplish. There's no point to pop a message box on the server within an aspnet application. What do you really want to do? There are ways to run a VBS script on the server, but let's hear what you want it for, first - Cheeso 2012-04-08 20:30
I needed to run an script that does several querys in the server database, generates several other files with the result of the querys and execute other .vbs files that use the files generated. One script to rule them all, but still needed to be executed from an aspx file - Rojas Azules 2012-07-03 22:04


4

A vbs script doesn't compile and execute. It's interpreted by wscript or cscript.

Try

process.StartInfo.FileName = "cscript";
process.StartInfo.Arguments = Request.MapPath("displayHelloWorldOnTheServer.vbs");
process.Start();
2012-04-04 18:34
by Kodra
Ads