Solved

Execute exe outside of IIS7 called from HTML

Posted on 2010-08-19
8
944 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 40

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 40

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
 
LVL 40

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 40

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 40

Accepted Solution

by:
Kyle Abrahams earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

929 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now