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?
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();