I have a VBScript that checks to see if MS Word is running hidden, makes it visible, then hides it again.
here is the script code that works fine when I double click the file in Explorer:
dim oWord
Dim wshShell, btn
Set wshShell = WScript.CreateObject("WScript.Shell")
set oWord = getobject(, "Word.Application")
if isobject(oWord) then
on error goto 0
wshShell.Popup "Word is running, making visible", 7, "ALPS Push print", &H0 + &H40
oWord.visible=true
wshShell.Popup "MS Word is now visible" & vbcrlf & vbcrlf & "Waiting 30 seconds then hiding it", 30, "ALPS Push print", &H0 + &H30
oWord.visible=false
else
wshShell.Popup "Word is not running" & vbcrlf & vbcrlf & "Quitting", 7, "ALPS Push print", &H0 + &H40
end if
It works find when I run it, but when it runs under Task Scheduler it fails so I created a batch file to launch it
wscript C:\dev\checkALPS.vbs
Now when I try to run it from the Task Scheduler, it still fails with the below error message
---------------------------
Windows Script Host
---------------------------
Script: C:\dev\checkALPS.bat
Line: 7
Char: 1
Error: ActiveX component can't create object: 'getobject'
Code: 800A01AD
Source: Microsoft VBScript runtime error
What can I do to get this working?