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

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

问题描述

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



让我告诉你一切我有...我没有得到任何错误,它只是不是运行正常。



任务计划程序时间轴




  • 事件110 任务由用户触发(Task Scheduler启动{6569c7af-fed8-456b-8c8e-9d1653b8c15a}用户tsee的任务\Test实例。

  • 事件319 任务引擎收到消息开始任务

  • 事件100 任务启动 - 任务计划程序启动{6569c7af -fed8-456b-8c8e-9d1653b8c15a}用户METRO\tsee的\Test任务的实例。

  • 事件200 - 任务计划程序在任务\Test的实例{6569c7af-fed8-456b-8c8e-9d1653b8c15a}中启动了C:\Users\tsee\Desktop\vbsTest\runTest.vbs的操作。 / li>
  • 事件129 创建任务处理ess - 任务计划程序启动任务\Test,具有进程ID 8964的实例C:\Windows\System32\WScript.exe。



之后,它只是说运行并且不执行任何操作。



我的VBScript :( runTest.vbs)

  Dim xlApp 
Dim xlBook

设置xlApp = CreateObject(Excel.Application)
设置xlBook = xlApp.Workbooks.Open(\\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.xlsm ,0,True)
xlApp.RunrunTaskTest
xlBook.Close
xlApp.Quit

设置xlBook =没有
设置xlApp =没有

我的excel Sheet和宏:(runTask.xlsm)

  Sub runTaskTest()
Dim erow As Long

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

单元格(错误+ 1,1).FormulaR1C1 =此测试成功: &安培;现在

ThisWorkbook.Save
End Sub

任何帮助非常感谢感谢提前!



路径网络:

解决方案

进一步评论



修改VBS文件

  Dim xlApp 
Dim xlBook

设置xlApp = CreateObject(Excel.Application )
设置xlBook = xlApp.Workbooks.Open(\\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.xlsm,0,False)

xlApp.DisplayAlerts = False
xlApp.Visible = False

xlApp.RunrunTaskTest

xlBook.Saved = True
xlBook.Save

xlBook.Close
xlApp.Quit


设置xlBook =没有
设置xlApp =没有

和您的宏

  Sub runTaskTest()
Dim erow As Long
erow = Sheets(1).Cells(Rows.Count,A)。End(xlUp).Row
Sheets(1)电子邮件(erow + 1,1).Value =这个测试成功了:&现在

ThisWorkbook.Saved = True
ThisWorkbook.Save
End Sub

,它应该工作


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.

Task scheduler Timeline

  • 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\tsee".
  • Event 200 Action Started - Task Scheduler launched action "C:\Users\tsee\Desktop\vbsTest\runTest.vbs" in instance "{6569c7af-fed8-456b-8c8e-9d1653b8c15a}" of task "\Test".
  • Event 129 Created Task Process - Task Scheduler launch task "\Test" , instance "C:\Windows\System32\WScript.exe" with process ID 8964.

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

My VBScript: (runTest.vbs)

Dim xlApp
Dim xlBook

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.xlsm", 0, True)
xlApp.Run "runTaskTest"
xlBook.Close
xlApp.Quit

Set xlBook = Nothing
Set xlApp = Nothing

My excel Sheet and Macro: (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!

Path network:

解决方案

Further to the comments

modify your VBS file

Dim xlApp
Dim xlBook

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.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

and your macro

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

and it should work

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

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