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?

2
  • 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. Commented Apr 8, 2012 at 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. Commented Jul 3, 2012 at 22:04

1 Answer 1

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.