views:

539

answers:

2

I have what should be a simple thing but my unfamiliarity with .NET and web programs is hindering me. I'm a straight up old-school C programmer who has been programming ASP and ASP.NET lately for an ecommerce site.

I have an ASP program that synchronizes 2 databases. I also have a VB.NET program compiled down to an EXE that fills the source database before the synch happens. In the back of my mind I know I should be able to link the VB & ASP .NET programs together since that's the power of .NET. Alternatively, if I could run the EXE from ASP it would be just as well for my project. I do have the source to both programs. The ASP script was written with a text editor - the VB was in VB 2008 Express.

Please assume I know nothing of linking assemblies and such because I don't - I just read that in an article. I'd prefer ASP but if necessary I could use the ASP.NET script to launch the EXE. The code is legacy ASP with VBScript so all our ASP.NET stuff is the VB flavor as well. C# makes my other programmer's head hurt so for his sake this will have to remain VB.

Is there a way I can relatively easily launch the EXE pre-sync program and have it run when the ASP synch script starts?

The server is MS Windows Server 2003 SP2 / IIS 6.0 / the .NET version is 2.0.50727.3603. Thanks!

By the way - I'd love to "learn to use .NET properly" but time is short for this project and in-depth research will have to wait.

EDIT: Aaron's answer below gets me most of the way to the solution but I'm getting:

Exception Details: System.ComponentModel.Win32 Exception: Access is denied
Source Error: Line 17: process1.Start();
Ideas anyone?

SOLUTION: Aaron's answer below plus the knowledge that ~/ in MapPath is the virtual root of the website and the file to run is relative to that.

+3  A: 

// Create An instance of the Process class responsible for starting the newly process.

System.Diagnostics.Process process1 = new System.Diagnostics.Process();

// Set the directory where the file resides

process1.StartInfo.WorkingDirectory = Request.MapPath("~/");

// Set the filename name of the file you want to open

process1.StartInfo.FileName = Request.MapPath("foo.exe"); 

// Start the process

process1.Start(); 
Aaron M
Ok, off the starting blocks but now I get this:Exception Details: System.ComponentModel.Win32Exception: Access is deniedSource Error: Line 17: process1.Start();Ideas?
Deverill
I would say it is most likely a permissions issue. By default they don't want web requests to be able to go off and execute files on the web server. Make sure the file is accessible by the user/group your web server is running as (but make sure its not writeable).
ghills
My ASP.NET Machine Account and Internet Guest Account both have Read/Execute permissions on the executable. I gave "Everyone" Read/Execute permissions but that didn't help either.
Deverill
Make sure they also have permission on the directory.
Aaron M
this link has some information on setting the permissions correctlyhttp://support.microsoft.com/default.aspx?scid=kb;en-us;555134
Aaron M
Perfect, Aaron! I still have a fault but it's running as seen in Task Manager. Thanks a million!
Deverill
+1  A: 

If you have the source for both then you could open the project for the EXE and copy the functionality to a new class library, then reference this class library in the web app and call the method that does the database filling from the web app.

Russ Bradberry
Maybe if I were more sophisticated I could do this but as is I'm afraid it's over my head. The ASP.NET I've learned has been from an old ASP programmer that thinks the IDE is a foreign thing for people who don't know how to program. I know, dumb but I'm afraid as it is I'd be lost referencing things in the ASP side. Thanks though! I'll keep it in mind for when I learn to use it properly!
Deverill