locked
scripting ms-word from schtasks failed RRS feed

  • Question

  • Hello,

    I have a vbs script that use ms-word. When I run the script from schtasks from a user account, it failed. When I run the same script from schtasks with a administrator account, it works

    question : ms-word doesn't support scripting in background from a user account ?

    more info:

    The test vbs file : test.vbs (simply load the file c:\data\temp\test.docx)
      Dim wdo ' As Word.Application
      Dim wdocs ' As Word.Documents
      On Error Resume Next
      Set wdo = CreateObject("Word.Application")
      Set wdocs = wdo.Documents
      Set wdoc = wdocs.Open("c:\data\temp\test.docx")
      WScript.Echo "Open Error: " & Err.Number
      wdoc.Close 0
      wdo.Quit 0

    and a batch file that calls test.vbs : test.cmd
      cscript c:\data\temp\test.vbs //nologo > c:\data\temp\test.log

    I run test.cmd from a console (and I am logged as a "normal" user (not an administrator))
    C:\data\temp>test.cmd
    C:\data\temp>cscript test.vbs //nologo  1>c:\data\temp\test.log
    C:\data\temp>type test.log
    Open Error: 0
    No error detected : the script works fine

    Now I run test.cmd from schtasks (and I an still logged on the station)
    >schtasks /create /st HH:MM:SS /sc once /tn test_vbs /tr C:\data\temp\test.cmd
    C:\data\temp>type test.log
    Open Error: 0

    Well, that's work also

    I retry the same test but now, I close my session on the station (when test.cmd will be started, there is no open session for the user account)
    In this case, the script failed : the .vbs can't create object
    (If I use an administrator account => it works)

    * a permission problem ?
    * a cscript limitation (cscript must access to the display) ?

    Any ideas ?

    Monday, September 23, 2013 2:05 PM

All replies

  • I am doing some research and test in my lab. Appreciate your patience.

    Cheers,
    Tony Chen
    Forum Support
    ________________________________________
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact tnmff@microsoft.com.

    Wednesday, September 25, 2013 11:48 AM
  • Hello,

    I've created a normal user on the test machine. Create a test.vbs and test.cmd, then build a schedule task as you description. Everything runs fine and no error message appears. I think the script itself is ok and the cscipt is no limitation for this case.

    I have not tested the behavior when I close the current session and run the task schedular as background.

    If this issue can be reproduced in my lab, there might be doubts as following:

    1. No enough permission of c:\data\temp\ when no session login.

    2. No enough permission to run the script via task scheduler when no session login.

    3. There is no permission to call CreateObject("Word.Application") when no session logon and vba failed to create the object.

    Thanks.

    Cheers,
    Tony Chen
    Forum Support
    ________________________________________
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact tnmff@microsoft.com.



    • Edited by Tony Chen CHN Monday, September 30, 2013 11:41 AM
    • Marked as answer by pfxxx Monday, September 30, 2013 1:59 PM
    • Unmarked as answer by pfxxx Monday, September 30, 2013 1:59 PM
    Monday, September 30, 2013 11:28 AM
  • Note : I use Windows XP

    > I have not tested the behavior when I close the current session and run the task schedular as background.

    but the problem arises in this case specifically

    > 2. No enough permission to run the script via task scheduler when no session login.

    I think this is the origin of the problem

    There are some log entries in the eventvwr (Microsoft Office Alerts)

    Here is a typical entry (in french) :

    source : Microsoft Office 14 Alerts
    entry event = 300
    message :

    Microsoft Word
    Impossible d'enregistrer le fichier de corrections automatiques MSO1036.acl.
    Ce fichier est peut-être en lecture seule ou vous n'avez pas l'autorisation de le modifier.
    P1: 700095
    P2: 14.0.6029.1000
    P3:
    P4:

    It seems that msword has no write access when it runs under schtasks

    Maybe must I modify the COM/DCOM authorizations ? but which one ? ... this is *the* question ! ;-)

    Monday, September 30, 2013 2:13 PM
  • Hi,

    Sorry for the delay, I've got the same result when running the task schedular as background with no session logon. I have no idea whether it could be solved by modifying the COM/DCOM authorization yet. Just let you know we are still doing research and might try to involve someone familiar with this topic to further look at this issue. Appreciate your patience.

    Cheers,
    Tony Chen
    Forum Support
    ________________________________________
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact tnmff@microsoft.com.

    Sunday, October 6, 2013 9:33 AM
  • >> Appreciate your patience.

    no problem ... I appreciate your help


    Sunday, October 6, 2013 1:25 PM
  • In my mind, OS runs task scheduler as background with the system permission, it's ok.
    But Call Creatobject should be executed when user's session logon. I cannot confirm it.<o:p></o:p>

    Whatever, I've escalated the issue:)

    Cheers,
    Tony Chen
    Forum Support
    ________________________________________
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact tnmff@microsoft.com.<o:p></o:p>


    Monday, October 7, 2013 9:03 AM
  • Hello,

    Microsoft Office applications (like Word, Excel and PowerPoint) were not designed and tested to run in non-interactive mode. Hence, automation of Office applications is not recommended and supported in a non-interactive environment. For more details, please have a look at the below KB article:

    http://support.Microsoft.com/kb/257757

    -Ajay

    • Proposed as answer by Ajay Bandooni Wednesday, October 9, 2013 3:23 PM
    Monday, October 7, 2013 3:26 PM