locked
WScript.Shell.Run (cmd /c schtasks /run /s \\server /tn AM) does not work on IIS 5.0 RRS feed

  • Question

  • User-596605856 posted

    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.

    Is there a security issue that I'm not aware of?

    Please help.

    Regards.

    Monday, June 4, 2007 6:02 PM

Answers

  • User113421904 posted

    Hi,

    First, Please make sure Remote Scheduled Tasks Management is allowed in Windows FireWall:

    Start, Control Panel, Security, Allow a program through Windows Firewall, and then select the Remote Scheduled Tasks Management check box.

    Second, In Task Scheduler, you can connect to the remote computer using different credentials than the credentials for the current user. Click on the Connect as another user check box and then click the Set User button. Enter the user name and password of the user credentials that you want to use.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, June 5, 2007 1:44 AM

All replies

  • User113421904 posted

    Hi,

    First, Please make sure Remote Scheduled Tasks Management is allowed in Windows FireWall:

    Start, Control Panel, Security, Allow a program through Windows Firewall, and then select the Remote Scheduled Tasks Management check box.

    Second, In Task Scheduler, you can connect to the remote computer using different credentials than the credentials for the current user. Click on the Connect as another user check box and then click the Set User button. Enter the user name and password of the user credentials that you want to use.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, June 5, 2007 1:44 AM
  • User-596605856 posted

    On which server do I need to allow Remote Scheduled Tasks?  I followed the path you specified but I couldn't find it.  I don't see the Connect as another user check box. 

     Here is my goal...

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

    Regards.

    Tuesday, June 5, 2007 1:56 PM
  • User113421904 posted

    Hi,

    I mean the remote computer should allow remote task scheduling if the Windows Firewall is enabled. The following link provide some more information and some examples:

    http://technet2.microsoft.com/WindowsServer/en/library/1d284efa-9d11-46c2-a8ef-87b297c68d171033.mspx#BKMK_remote

    Hope it helps.

    Sunday, June 10, 2007 10:11 PM