asp.netweb-servicesiisexe

Running .exe from aspx webservice does not work after hosting on IIS


I have a vb6 .exe which runs a SQL command during an .aspx web service method. It runs well when debugging, but when I run it after hosting in IIS, it shows an error.

This is my code:

System.Diagnostics.ProcessStartInfo ASN_GRN = new System.Diagnostics.ProcessStartInfo();
ASN_GRN.FileName = exePath;
ASN_GRN.WorkingDirectory = basePath;
ASN_GRN.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
ASN_GRN.CreateNoWindow = true;
ASN_GRN.UseShellExecute = false;
ASN_GRN.RedirectStandardOutput = true;
ASN_GRN.RedirectStandardError = true;

if (File.Exists(ASN_GRN.FileName))
{
    try
    {
        using (System.Diagnostics.Process process = System.Diagnostics.Process.Start(ASN_GRN))
        {
            // This launches the console app
        }
    }
    catch (Exception ex)
    {
    }
}

When I run it after hosting in IIS, I get this error:

Run-time error '-2147467259 (80004005):
[DBNETLIB] Connection Open [Connect()]. SQL Server does not exists or access denied.

aspx_webservice_exe

Thanks in advance


Solution

  • I was using MSSQL connection open in my vb6 file

        Dim cnn As ADODB.Connection
        Dim rst As ADODB.Recordset
        Set cnn = New ADODB.Connection
        cnn.Open strConn 'where the error was thrown as in my question
    

    I migrated to aspx web site and

    1. set permission for the exe to everyone security add everyone with all permissions

    2. then I called Process.Start from C# aspx website as per this answer

        Process proc = new Process();
        proc.StartInfo.FileName = "SAP_to_MSSQL.exe";
        proc.WorkingDirectory = @"D:\exepath\";
        proc.StartInfo.UseShellExecute = true;
        proc.StartInfo.Verb = "runas";
        proc.Start();
    

    and it runs fine from my IIS-hosted aspx web site. Thanks