Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2005
    Posts
    6
    Rep Power
    0

    Question 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:


    ASPEXEC:


    <%
    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
    %>



    WSH:


    <%
    Dim oWSH

    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!

    John
  2. #2
  3. Spell Breaker
    ASP Adventurer (500 - 999 posts)

    Join Date
    May 2004
    Posts
    990
    Rep Power
    11
    You can't do it. Try use schedule.
    It's nice to be important, but it's more important to be nice.
  4. #3
  5. Beyond The Impossible
    ASP Adventurer (500 - 999 posts)

    Join Date
    Sep 2003
    Location
    Shawnee Mission, KS, USA
    Posts
    921
    Rep Power
    13
    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
    John Shepard
    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 &#91;code&#93; and &#91;/code&#93; tags.
    X-Login and X-Send
  6. #4
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2005
    Posts
    6
    Rep Power
    0

    Question


    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!

    John





    Originally Posted by freeasphelp
    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
  8. #5
  9. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    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...
  10. #6
  11. Beyond The Impossible
    ASP Adventurer (500 - 999 posts)

    Join Date
    Sep 2003
    Location
    Shawnee Mission, KS, USA
    Posts
    921
    Rep Power
    13
    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.
  12. #7
  13. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    those permissions are nightmare, yes. and it's far worse on 2003 Server as far as I've heard.
  14. #8
  15. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2005
    Posts
    6
    Rep Power
    0
    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
  16. #9
  17. Spell Breaker
    ASP Adventurer (500 - 999 posts)

    Join Date
    May 2004
    Posts
    990
    Rep Power
    11
    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 02:22 PM.
  18. #10
  19. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    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.
  20. #11
  21. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2005
    Posts
    6
    Rep Power
    0
    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.

    Any ideas?

    Thanks
  22. #12
  23. Senior Fire Wizard
    ASP Mastermind (5000+ posts)

    Join Date
    Feb 2005
    Location
    Ashford, Kent. England
    Posts
    5,651
    Rep Power
    314
    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
  24. #13
  25. Spell Breaker
    ASP Adventurer (500 - 999 posts)

    Join Date
    May 2004
    Posts
    990
    Rep Power
    11
    ping.exe is small app that doesn't have any dll attachted.
  26. #14
  27. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2922
    Originally Posted by elijathegold
    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
    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.....

    ping.exe is small app that doesn't have any dll attachted.
    any command line application would work via the Shell. problem is only with GUI applications.
  28. #15
  29. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2005
    Posts
    6
    Rep Power
    0
    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.
Page 1 of 2 12 Last
  • Jump to page:

Similar Threads

  1. Running a Server Side Program using ASP
    By newland in forum ASP Development
    Replies: 5
    Last Post: May 27th, 2005, 07:18 AM
  2. Connecting to SQL Server
    By cmurph1624 in forum Microsoft SQL Server
    Replies: 2
    Last Post: May 23rd, 2005, 05:57 PM
  3. Web serverístatistical analysis
    By cso in forum ASP Development
    Replies: 0
    Last Post: April 19th, 2003, 12:35 PM
  4. Executing a server side EXE and returning data to an ASP page
    By Steve Schofield in forum ASP Development
    Replies: 0
    Last Post: March 18th, 2001, 02:27 PM
  5. Resume for ASP, JAVA, JSP & Servlet
    By Steve Schofield in forum Programmers for Hire
    Replies: 0
    Last Post: April 18th, 2000, 03:47 AM

IMN logo majestic logo threadwatch logo seochat tools logo