I have a single form application which checks user states continuously via timer. I want to start the same .exe by using process.start("C:\inetpub\wwwroot\mywebapp\Checker\checker.exe") in Web Application. The exe appears in System processes list (not appear in application list in Windows Task Manager) after the code executed but it does nothing. It is not changing the user states nor sending Data to Database. But when I start same .exe manually on double clicking, it start working and it also appears in Windows Task Manager Application list and in Process Lists. The .exe is made with C#.Net and is executed file of C# windows application.
-
possible duplicate of [.NET Process.Start default directory?](http://stackoverflow.com/questions/114928/net-process-start-default-directory) – Xavier J Jan 28 '14 at 17:34
1 Answers
When launched by IIS the process will run under the account that started it, which will be the w3wp
processes that is running your web application. Because this isn't your account it won't show up in task manager until you select the "show processes from all users" option. When you run it via a double click it is running under your account, so will be visible.
If the changes and database access rely on using your account to gain access then this wont work when it runs from within IIS. For example, if your database connection is done using "Windows Authentication" then it will try to log in as the IIS account, which is unlikely to work.
To fix this you can launch the processes by specifying a username/password in the ProcessStartInfo
structure. However, this will require you to embed your password somewhere, which may not be desirable. Alternativly look at changing the database connection string so that you specify the logon credentials explicitly.

- 60,939
- 11
- 97
- 136
-
You are right Sean, when I used the below code in Visual Studio debugger, it works fine and launched the exe and given me the response by updating database etc. But when I deployed it in IIS and used to run the code, it shows me .exe in Processes list but does nothing. I mean the .exe appeared in processes list but it is like a die, does nothing even if I change its connection string etc. I should show me some error message when I change Table name or connection string. – ZahidKakar Jan 29 '14 at 06:39
-
myprocess.StartInfo = new ProcessStartInfo("C:\\inetpub\\wwwroot\\visionweb\\UploadedLogo\\Checker\\OnlineOffline.exe"); myprocess.Start(); – ZahidKakar Jan 29 '14 at 06:40
-
As a test try setting the `Username` and `Password` properties of `ProcessStartInfo` to your details and run it from IIS. – Sean Jan 29 '14 at 08:48