Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP.NET and IIS 5.0

    Hello,

    I am trying to use the wScript object in my ASP.NET page to trigger a scheduled task on a server on the network. I am able to accomplish this locally however, when I publish the page onto the web server I get nothing. Here's what I have so far...

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim wshell As Object
    wshell = CreateObject("WScript.Shell")

    wshell.run("cmd /c schtasks.exe /run /s server2 /tn AM")

    wshell = Nothing

    End Sub

    When a user clicks on this button the command schtasks.exe is executed on the web server which triggers the scheduled task on server2. Again, it works fine locally, but when I publish it on the webserver the only thing I see happening on the web server is in the taskmanager the process schtasks.exe is running, but the command is not passing through to server2. I know the cammand works because when I open a command window on the web server and type it in, I can see the execution on server2.

    Please help.

    Regards.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ASP.NET and IIS 5.0

    This sounds like a security/permissions issue. How is the identity/impersonation set for the IIS site?

    Generally, there are two ways to set up the site:
    1) The users will anonymously log into the site. All pages/scripts on the site will be run under the specified account (the "anonymouse" user).
    2) Integrated Windows Authentication - All pages/scripts on the site will be executed under the AD permissions of each respective user

    Either approach will work as long as the desired user(s) have permissions to execute the script (and executable).

    Keep us posted with the results!

  3. #3
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ASP.NET and IIS 5.0

    Mark,

    Thanks for the reply. I figured it might be a security issue, but i tried every possible way and it still wouldn't work. On the webserver, the whole folder is given permission to ASPNET full control and read, write, execute scripts are enabled.

    Note that the command is sending the command to a differnt server and not the webserver:

    cmd /c schtasks /run /s server2 /tn AM

    When I logon to the web server as admin and execute the cammand from cmd window, everything works fine. When I browse the aspx page and click on the button expecting that the same thing will happen, instead all I see happening is the process schtasks.exe running on the webserver, but nothing is happening on server2.

    Can you please guide me through.

    My webserver is windows 2000 running IIS 5.0 and server2 is windows 2003 server on the same network.

    Regards.

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ASP.NET and IIS 5.0

    Sounds like the problem is the ASPNET account. It's typically a very restrivtice account on the box. Essentially, despite having free permissions wihtin the web folder, the ASPNET account is unable to pass calls around to the network.

    Are you on a domain? You'll want to use a domain account with sufficient permissions - not a local box account. Or, if you're not on a domain, you'll want to use the Network Service account (I think 2000 called it NT Authority).

    I'm a developer and I usually take the typical developer approach - create an account with full domain admin permissions to make sure the command works. Then I back down the permissions until it stops working. Typically, Netowork Admin types take the opposite approach - start with the most restrictive and start un-restricting until it starts working.

    The fact that the command works for your user account is a sign that this is definitely a permissions issue... Keep playing with it until you get the results you desire. You're on the right path.

  5. #5
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ASP.NET and IIS 5.0

    Mark,

    I gave the executable schtasks.exe, which is on my webserver, full control to everyone and gave the scheduled task AM, which is on my Server2, full control to everyone. It still didn't work. The process runs on the webserver, but the task does not run on Server2. Do I need to set any switches for the website using IIS manager?

    My ultimate goal is the following:

    I would like to run a scheduled task on Server2 running Windows 2003 from an aspx page hosted on my WebServer running Windows 2000. There's got to be an easier way to accomplish this, but I don't know how.

    Regards,
    RR

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ASP.NET and IIS 5.0

    I think we're misunderstanding each other.

    The file permissions are not the issue here. The issue is the permission to send any external command outside of the box. The ASPNET user typically does not have any permissions to leave the box on which it's running - even if it has permissions to run the EXE in question.

    Are you running on a domain? If so, you will need to change the Anonymous user of your site (in IIS Manager) to an account that domain-level access to the target machine (Server 2003).

    If both machines are not members of the same domain then you will need to be sure that the Anonymous account has the appropriate machine-level permissions on the target box as well as the appropriate permissions to reach outside of the source box.

    Alternatively, you can set the web authentication mode to Integrated Windows Authentication and it will work for any user who has the appropriate permissions.

    There could also be some Windows 2000 vs. 2003 differences at play. Unfortunately, this is outside my area of expertise and there's probably not much more I can do to help... Good luck! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •