任务计划程序正在运行但未完成或正常工作 VBscript [英] Task Scheduler running but not finishing or working properly VBscript

查看:60
本文介绍了任务计划程序正在运行但未完成或正常工作 VBscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行 excel 宏的 vbscript.一切似乎都正确,但它并没有像我希望的那样工作.任务开始了,然后只是持续运行而不做任何事情.

I have a vbscript that runs an excel macro. Everything seems right, but it is not working as I had hoped. The task starts but then just continuously running without doing anything.

让我向您展示我拥有的一切...我没有收到任何错误,只是运行不正常.

Let me show you everything I have... I don't get any errors, it just isn't running properly.

任务调度程序时间线

  • 事件 110 由用户触发的任务(任务计划程序为用户tsee"启动了任务Test"的{6569c7af-fed8-456b-8c8e-9d1653b8c15a}"实例.
  • 事件 319 任务引擎收到开始任务的消息
  • 事件 100 任务已启动 - 任务计划程序已启动用户METRO see"的Test"任务的{6569c7af-fed8-456b-8c8e-9d1653b8c15a}"实例.
  • 事件 200 操作已开始 - 任务计划程序在实例{6569c7af-fed8-456b-8c8e-9d1653b8c15a}"中启动了操作C:Users seeDesktopvbsTest unTest.vbs"任务Test".
  • 事件 129 已创建任务进程 - 任务计划程序启动任务Test",进程 ID 为 8964 的实例C:WindowsSystem32WScript.exe".
  • Event 110 Task Triggered by user (Task Scheduler launched "{6569c7af-fed8-456b-8c8e-9d1653b8c15a}" instance of task "Test" for user "tsee".
  • Event 319 Task engine received message to start task
  • Event 100 Task started - Task Scheduler started "{6569c7af-fed8-456b-8c8e-9d1653b8c15a}" instance of the "Test" task for user "METRO see".
  • Event 200 Action Started - Task Scheduler launched action "C:Users seeDesktopvbsTest unTest.vbs" in instance "{6569c7af-fed8-456b-8c8e-9d1653b8c15a}" of task "Test".
  • Event 129 Created Task Process - Task Scheduler launch task "Test" , instance "C:WindowsSystem32WScript.exe" with process ID 8964.

之后它只是说running"并且不执行任何操作.

After that it just says "running" and doesn't execute anything.

我的 VBScript:(runTest.vbs)

Dim xlApp
Dim xlBook

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("\fileserverhomesharesTseeMy DocumentsProgrammingTask Scheduler
unTask.xlsm", 0, True)
xlApp.Run "runTaskTest"
xlBook.Close
xlApp.Quit

Set xlBook = Nothing
Set xlApp = Nothing

我的excel表格和宏:(runTask.xlsm)

Sub runTaskTest()
    Dim erow As Long

    erow = Cells(Rows.Count, "A").End(xlUp).Row

    Cells(erow + 1, 1).FormulaR1C1 = "This test was successful : " & Now

    ThisWorkbook.Save
End Sub

任何帮助将不胜感激.提前致谢!

Any help would be much appreciated. Thanks in advance!

路径网络:

推荐答案

进一步评论

修改你的 VBS 文件

modify your VBS file

Dim xlApp
Dim xlBook

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("\fileserverhomesharesTseeMy DocumentsProgrammingTask Scheduler
unTask.xlsm", 0, False)

xlApp.DisplayAlerts = False
xlApp.Visible = False

xlApp.Run "runTaskTest"

xlBook.Saved = True
xlBook.Save

xlBook.Close
xlApp.Quit


Set xlBook = Nothing
Set xlApp = Nothing

和你的宏

Sub runTaskTest()
    Dim erow As Long
    erow = Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
    Sheets(1).Cells(erow + 1, 1).Value = "This test was successful : " & Now

    ThisWorkbook.Saved = True
    ThisWorkbook.Save
End Sub

它应该可以工作

这篇关于任务计划程序正在运行但未完成或正常工作 VBscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆