Calling a legacy executable from an ASP.NET web service can work on a developer's computer and fail after deployment to Internet Information Services (IIS). A common reason is that the process runs under a different Windows identity on the server, with different file, database, and network permissions.
This guide uses a VB6 executable that connects to SQL Server as an example. The same troubleshooting principles apply to other native or .NET executables launched by an ASP.NET application.
Important correction: do not use runas or Everyone permissions as the fix
An earlier version of this article suggested granting the Everyone group access to the executable and setting ProcessStartInfo.Verb = "runas". Those are not suitable general-purpose fixes for a production IIS application. Giving broad permissions does not grant the process SQL Server access, and asking the Windows shell to elevate a process is not a reliable way to elevate a non-interactive IIS worker process.
The safer approach is to identify the account that runs the application, grant that account only the permissions it needs, and configure SQL Server access for that identity.
Why an executable behaves differently under IIS
When a web application starts a child process, the child normally runs in the security context of the IIS worker process. It does not automatically run as the Windows account used to sign in to Visual Studio or to browse the server.
On modern IIS installations, an application pool commonly uses a virtual identity such as IIS APPPOOL\MyAppPool. The configured identity may instead be a custom service account, Network Service, or another account. The permissions available to the child executable follow the security context used to launch it.
Step 1: identify the effective Windows identity
Temporarily record the identity from the web application using your normal application logger:
using System.Security.Principal;
string identityName = WindowsIdentity.GetCurrent().Name;
// Write identityName to a restricted application log.
Check the application's impersonation settings as well. In classic ASP.NET applications, impersonation can affect the identity used while handling a request. Do not expose this diagnostic information in a public response, and never log passwords or connection-string secrets.
Step 2: grant the application pool only the required file permissions
Give the relevant application pool identity Read and Execute access to the executable and its required files. For example, if the pool is named MyAppPool:
icacls "C:\Apps\MyJob" /grant "IIS AppPool\MyAppPool:(OI)(CI)RX"
If the executable needs to write logs or output files, use a separate directory and grant Modify access only to that directory:
icacls "C:\Apps\MyJob\Logs" /grant "IIS AppPool\MyAppPool:(OI)(CI)M"
Replace the paths and pool name with the values on your server. Avoid granting permissions to Everyone, and do not grant Modify or Full Control over the entire application directory unless the application genuinely requires it.
Step 3: verify SQL Server access under the service identity
A file permission only determines whether the process can read or execute files. It does not grant database access. If the executable connects to SQL Server using Windows Integrated Authentication, SQL Server must recognize and authorize the Windows identity used by the process.
- SQL Server on the same machine: check whether the application pool identity has a SQL Server login and the minimum database permissions required by the job.
- SQL Server on another domain machine: an application pool using
ApplicationPoolIdentitynormally accesses network resources as the IIS server's computer account, such asDOMAIN\WEB01$. Confirm the actual identity and grant only the required SQL permissions, or configure a dedicated domain service account or group Managed Service Account where appropriate. - SQL authentication: verify the server, instance, database, username, and password. Keep credentials out of source code and protect them using an appropriate configuration or secret-management mechanism.
- Legacy ODBC connections: check whether the executable expects a User DSN that exists only in your interactive Windows profile. A VB6 executable is typically 32-bit, so verify that the matching 32-bit ODBC driver and DSN are configured for the server-side execution context.
The error SQL Server does not exist or access denied does not prove that the executable lacks file permissions. Also verify the SQL Server instance name, enabled network protocol, listening port, DNS resolution, firewall rules, and credentials from the IIS server itself.
Step 4: start a non-interactive process without shell elevation
For a short-running command-line executable that is designed to run without a desktop or user interaction, use an explicit executable path and disable shell execution:
using System;
using System.Diagnostics;
using System.IO;
string exePath = @"C:\Apps\MyJob\LegacyJob.exe";
string basePath = Path.GetDirectoryName(exePath);
if (!File.Exists(exePath))
{
throw new FileNotFoundException("The executable was not found.", exePath);
}
var startInfo = new ProcessStartInfo
{
FileName = exePath,
WorkingDirectory = basePath,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process process = Process.Start(startInfo))
{
if (process == null)
{
throw new InvalidOperationException("The executable could not be started.");
}
// Use a short timeout only for jobs that are safe to run in a web request.
if (!process.WaitForExit(30000))
{
throw new TimeoutException("The executable did not finish within 30 seconds.");
}
if (process.ExitCode != 0)
{
throw new InvalidOperationException(
"The executable returned exit code " + process.ExitCode + ".");
}
}
This sample deliberately does not set Verb = "runas" and does not enable shell execution. It also does not redirect standard output or error because the sample does not read those streams. If you do redirect them, read both streams asynchronously or concurrently so that a full pipe buffer cannot cause the child process to hang.
Use a fixed, server-controlled executable path. Validate any arguments before passing them to the process; do not concatenate untrusted request values into a command line. Log the process start time, completion time, exit code, and relevant error details in a restricted log.
Step 5: move long-running work out of the web request
Waiting for an executable ties up an ASP.NET request and can run into request timeouts, application-pool recycling, or overlapping executions. For work that may take a long time, use a job queue and a separate Windows Service or .NET Worker Service. Run that worker under a dedicated least-privilege service identity, record job status, and let the web application report progress.
Executables launched by IIS must not depend on interactive desktop windows, message boxes, or a logged-in user's profile. If the legacy program requires those features, redesign the integration rather than trying to make IIS interact with the desktop.
Why runas is not an IIS permissions solution
The runas verb asks the Windows shell to use an elevation action. IIS is a non-interactive server environment, so an elevation prompt cannot be handled like a prompt on a developer's desktop. In addition, UseShellExecute = true is incompatible with redirecting the child process's standard output and error streams.
Most importantly, elevation is not a substitute for correctly configuring the application's database identity. Grant the service account the exact file, network, and SQL permissions it needs instead of trying to run the web application's child process as an administrator.
Key takeaways
- A child process started by an IIS application normally runs in the worker process's security context.
- Read and Execute access to an EXE does not automatically grant SQL Server access.
- Check the actual Windows identity, SQL authentication mode, network path, and any ODBC driver or DSN dependencies.
- Do not use
Everyonepermissions orrunasas a general production fix. - Use a separate background worker for long-running or privileged operations.
Microsoft references
- Application Pool Identities in IIS
- Understanding identities in IIS
- ProcessStartInfo class
- ProcessStartInfo.UseShellExecute
Author: Algolassi
Originally published: October 9, 2025
Topics: ASP.NET, IIS, Windows process execution, SQL Server, VB6
Comments will appear here when available.