SQL Server Agent Jobs

Hi,

I'm new to this area so hope someone can help:

1) Does SQL Server agent jobs support executing windows script files (.wsf)
I tried running using an Operating System Command (CmdExec) but nothing happened:

wscript c:\file.wsf

2) The windows script file is located on the Web Server.

I want to run the job from an SQL server calling the windows script file which is located on a different server. The target server is not an SQL Server. Is this possible


Thanks,
Martin



Answer this question

SQL Server Agent Jobs

  • Philip Lee

    Thanks Jens,

    I used CreateObject("MSXML2.ServerXMLHTTP") instead and it worked fine if I run it from windows explorer as my own user which has admin rights.

    But I'm getting a new problem when I run it from SQL Server Job. I put my own user as the owner but it seems to run as SYSTEM user. I had a look at the permissions for the SYSTEM user on the localserver for the file I wanted to execute and it appears to have full control access. Any ideas

    Executed as user: <localservername>\SYSTEM. Error Code: 0 Error Source= Microsoft VBScript runtime error Error Description: Permission denied Error on Line 4. The step failed.

    set oProcess = oController.CreateScript("c:\CallScript.wsf", "<remoteservername>")

    Martin


  • Floax

    Hi Jens,

    Thanks for your reply it was very helpful. I am having one problem with the remote windows script file (.wsf) as it appears to hang when I call it remotely. It does kick the script off and it runs until it hangs when I call send on a Microsoft.XMLHTTP object.

    Function GetHTML(strURL)
    Dim objXMLHTTP, strReturn
    Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
    objXMLHTTP.Open "GET", strURL, False

    ' it gets as far as here and then hangs:

    objXMLHTTP.Send

    strReturn = objXMLHTTP.responseText
    Set objXMLHTTP = Nothing
    GetHTML = strReturn
    End Function

    It's running as a NETWORK SERVICE user which I have given full permissions under the WMI control properties..

    If I call it locally it’s okay. Any ideas

    Thanks,
    Martin


  • k1dugar

    hi, if not too long ago...:)...did you solve this pb and how

    i am actually using xmlhttp.open from my javascript to get data from my sqlsrvr express DB running on windows2003, and keep on getting "permission denied" (looks like the DB connection fails)

    thanks for your input....i have been struggling quite a bit!

    y.


  • MKMahesh

    Hi,

    did you try running under a domain account rather than a network account. It could be that the service doesn’t have permissions using the internet connection (perhaps if you use a proxy server and you get a input box waiting for input credentials), so that would be an issue to look for.

    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---


  • Yarik

    This will execute the script on the SQL Server --> wscript c:\file.wsf, if its not present there it won’t execute. Remote execution of a script can be only done (AFAIK) bY initiating a remote script object http://msdn.microsoft.com/library/default.asp url=/library/en-us/script56/html/9d24095d-46a2-44d7-b900-fd4a0497a314.asp

    http://www.microsoft.com/technet/scriptcenter/topics/remote/rscripting.mspx

    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---


  • zhonglixunni

    Sorry, but I am out. I am not that deep in the object model that I could tell you which specific rights you need if you want to execute this. For using any shared network ressources (especially if you need access to ressources that need credentials) I would choose a (domain) network account for the SQL Server Agent.

    HTH, Jens Suessmeyer.

    ---
    http://www.sqlserver2005.de
    ---

  • Mahidhar

    As suggested by Jens have you tried by setting up a domain or local account with similar privileges of your account for this job, it looks like a permission issue on the database to perform this as a scheduled job.

    Also you can look at new SQLAgent roles to perform such function without granting SYSADMIN privlegs to that account.

    http://www.microsoft.com/technet/prodtechnol/sql/2005/newsqlagent.mspx

    http://support.microsoft.com/kb/915845 - fyi.



  • SQL Server Agent Jobs