Wscript .vbs文件未在Windows 10中的任务计划程序中运行

时间:2017-09-19 20:56:49

标签: scheduler wsh

我有一个wscript在我的桌面上运行.vbs文件。我希望它能在某个时间每天运行。我在Windows 10中设置了一个运行脚本的任务,但是在指定的时间没有任何反应。在调度程序的“action”选项卡下,我在Program / Script:输入行中有wscript.exe,在Add Arguments行中有文件路径。当我只是双击桌面上的.vbs文件时,它工作正常,但由于某种原因,任务调度程序无法启动它,即使我尝试在调度程序中单击“运行”进行测试。我一直在阅读一些论坛,可能它需要是一个cscript.exe,但我已经尝试过它不起作用。我的.vbs文件确实使用了wscirpt,所以我可能需要同时将脚本更改为cscript并重新运行它。我试过了,但它似乎没有用。在我的.vbs文件中的脚本下面。

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""

WScript.Sleep 3000

WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"

WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"

WScript.Sleep 5000

WshShell.SendKeys "XXXXX"
WshShell.SendKeys "{ENTER}"

WScript.Sleep 5000

WshShell.SendKeys "{ENTER}"

WScript.Sleep 5000

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\carls\Desktop\REIT Model\Model Forward\Stock Model REITs.xlsm")
objExcel.Application.Visible = True
objExcel.Application.Run "PortfolioEvaluator"

Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run "outlook"

WScript.Sleep 30000

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""

WScript.Sleep 3000

WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"

WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"

0 个答案:

没有答案