July 15th, 2005, 08:19 AM
aspexec help - executing a program on server
Hi, I need some help executing a program from an asp page.
I've tried using aspexec and wsh, here is the code for both:
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "C:\program name"
Executor.Parameters = "c:\autoexec.bat"
Executor.TimeOut = 9000 ' may take out
Executor.ShowWindow = True
Response.Write "Attempting to execute " & Executor.Application & "<br>"
strResult = Executor.ExecuteWinApp
Response.Write "The result of this call was: " & strResult
Set oWSH= CreateObject("WScript.Shell")
oWSH.Run "C:\program name", 1, True
set oWSH = nothing
Each program I try to execute, whether it be 'notepad' or an executable, just ends up hanging in task manager on the server.
This code is actually to be run for a self-terminating program, and it should kick itself out of task manager once it is completed. It does not, however, and has '00' for CPU usage at all times.
Any response is greatly appreciated! Thanks!
July 15th, 2005, 10:50 AM
You can't do it. Try use schedule.
It's nice to be important, but it's more important to be nice.
July 15th, 2005, 02:05 PM
I noticed in the ASPExecute you didn't close it out and the oWSH.Run, you might have to try another value. It works, you just have to figure out which works better. It is possible to do this though.
However the best way to do this, is using schedule, ASP 101 has an article on doing this the right way:
Getting Scripts to Run on a Schedule by John Peterson
Beyond The Impossible
Has a post helped you? Please show your apprecitation by clicking the
image in the right upper corner.
Posting code? Put your code between [code] and [/code] tags.
X-Login and X-Send
July 15th, 2005, 03:38 PM
Thanks for the responses!
Perhaps I wasn't that clear in my first post.
All I want is a link on a webpage to a .asp or some other type of file that will execute a program on the server. This program is in the same directry the .asp file is stored.
The program is self terminating, so it should kick itself out of task manager when it is finished.
The Schedule Info page you posted talks mainly about scheduling processes to run at certain times of the day. I am looking to run this .asp page on demand (when the client clicks it). The asp page will then run the program on the server.
Perhaps I am missing something on the ASP101 website that I need!
Originally Posted by freeasphelp
July 16th, 2005, 02:25 PM
as far as I know, this is not possible whatsoever due to permissions problem. even 3rd party components won't work, as it all run under the IIS process.
John, do you have working example of ASP code that cause Notepad to launch on the server as new GUI application? with or without components, I considered this to be impossible but as always I'd be glad to stand corrected and learn something new...
July 17th, 2005, 09:57 PM
Fluid Dynamics: perms.asp
If you can work out the permission issues it will work, but changing permissions to get this to work can make the system insecure. The best way is to use a schedule, as below.
July 18th, 2005, 02:30 AM
those permissions are nightmare, yes. and it's far worse on 2003 Server as far as I've heard.
July 18th, 2005, 01:17 PM
Again, thanks for the responses.
I've allowed full permission to all accounts on the web server and also gave full permission to the folder the executable is contained in.
Is it possible this is not a permissions issue? Maybe I am missing a permissions setting somewhere in IIS?
Also, is it necessary that IIS be restarted in order for these changes to go into affect? (I am on a remote machine and this server hosts websites other than my own). Thanks
July 18th, 2005, 01:20 PM
1.It's probably premission issue.
giving full premission is not really good idea.
2.i don't think you need restart the IIS you can stop and start your site.
Last edited by beercraft_asp; July 18th, 2005 at 01:22 PM.
July 18th, 2005, 02:40 PM
if you're hosted, there's no chance the host gave you full permissions. those permissions means very easy life for hackers, it's like leaving the door of your house wide open.
July 19th, 2005, 09:53 AM
I have stopped and restarted the website and I still can't get it to work.
I have tested granting full permissions to network users and still my program just hangs in the task manager.
Here is something interesting...If I run this code to execute a ping command it works just fine:
Set obj_Shell = CreateObject("WScript.Shell")
Set obj_WSH = obj_Shell.Exec("ping www.bbc.co.uk -w 10")
You can see ping.exe executing in the task manager for a few seconds, and then it successfully finishes.
But if I try to run my program (which is an executable that produces an Excel spreadsheet), it just hangs in the task manager and never executes.
July 19th, 2005, 10:01 AM
I seem to remember reading somewhere that in order to start a program with a gui on a server, you need to start it as the INTERACTIVE_USER. I think that was Windows 2003.
Please don't ask me how though, I think I'm repressing
And he picked it all up... in his pick-up.
Friends of Shemzilla
July 19th, 2005, 10:06 AM
ping.exe is small app that doesn't have any dll attachted.
July 19th, 2005, 12:40 PM
yeah, I also saw somewhere that for such things you have to change the basic windows permissions and make IIS run as admin account - among other things. would be nice to find someone who done that before, but maybe such person does not exist.....
Originally Posted by elijathegold
any command line application would work via the Shell. problem is only with GUI applications.
July 20th, 2005, 09:54 AM
You guys are absolutly right.
In IIS, if you go to Application Pools Properties and Click on the Identity tab, you can change the security account for the application pool.
I changed it from Network Service to Local System, which gives all clients full access to the system.
I then executed the asp page and the program ran fine and terminated like it was supposed to.
Now, what I need to do is give the Network Service Account permission to allow web users to execute files on the server. This will let me take it off the Local System account. I believe this option is in Local Security Policy or Services under Administrative Tools. I have been searching for this option, but I can't seem to find it. Does anyone have any ideas?
Thanks for all your help.