?
Solved

Execute exe outside of IIS7 called from HTML

Posted on 2010-08-19
8
Medium Priority
?
971 Views
Last Modified: 2013-12-25
I've written a small executable which I want to call another exe that is outside the wwwroot folder in IIS7.  I first type in the URL http://localhost/test.exe, then the test.exe will call Process.Start(@"C:\test2.exe").  

Now the problem is that test.exe does not have permission to execute because the user (the one who calls test.exe) does not have enough permissions.  Of course I tried to fixed this but it didn't work.  

I've tried many solutions and none have worked, here they are.
1. Changed Process.StartInfo.WorkingDirectory to "C:\"
2. Impersonated Local User (had to use direct windows calls, this did not throw an exception but the test2.exe did not execute)
3. Added/Changed permissions (IUSER,Local Service,Local Users, Network Service, Everyone)
4. Changed Process.Startinfo.UseShellExecute =false

Heres the exception thrown:
Unhandled Exception: System.ComponentModel.Win32Exception: Access is denied
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at ProcessStart.Program.Main(String[] args)
0
Comment
Question by:htn5ca
  • 5
  • 3
8 Comments
 
LVL 41

Expert Comment

by:Kyle Abrahams
ID: 33478446
When I did this I used the scheduled tasks to drive the calling (you can leave that configured with a user who has higher permissions).

http://stackoverflow.com/questions/542804/asp-netbest-way-to-run-scheduled-tasks
0
 

Author Comment

by:htn5ca
ID: 33478643
Sorry ged325 but I am looking for a more instantaneous answer because it is a time sensitive event.

The other exe just opens a socket (which iis7 won't allow me to do) and sends a command to a server.
0
 
LVL 41

Expert Comment

by:Kyle Abrahams
ID: 33484461
Is the EXE home grown or 3rd party?  There are ways to do it from within the application.  What is the purpose in limiting the range of ports used for outbound connections?  (Not questioning the validity of your need, but if you explain why there may be other ways around this.)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 41

Expert Comment

by:Kyle Abrahams
ID: 33484556
^^ should never do EE before my first cup of coffee.

You can issue a command from there to run a scheduled task the next second.  Do you need it to run sooner than that?

What if you moved the EXE into the folder to give users permission to run it (grant execute on the directory).
0
 

Author Comment

by:htn5ca
ID: 33513790
Well the whole purpose of calling another EXE outside of the IIS7 folder is because I do not have permission to create a socket connection to a server.  I've granted execute permission to the EXE, full control to IUSR (user that calls the exe) and even added all users with full permissions with no luck at all.  
0
 
LVL 41

Expert Comment

by:Kyle Abrahams
ID: 33514558
how sensitive is the timing?  

From my understanding you're trying to make an outbound connection from the server back to the client because you can't use the client to go back to the server?  More details of what you want to have happen (ideally) would be helpful.

0
 

Author Comment

by:htn5ca
ID: 33526803
Heres the scenario:

Some software would query my IIS server with something like "http://192.168.1.2/test.exe?Action=Start&IP=132.52.234.5"

My test.exe (hopefully) create a socket connection with 132.52.234.5 and send some set of commands that is hard coded.  

0
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 33530917
I would go back to my original suggestion of using a scheduled task to kick off the process.  You can schedule to execute 1 second after you get the request.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question