vbscript to open an excel file in Windows 10 via Task Scheduler -
i have script file i'm executing via task scheduler worked fine in windows 7, , not working in windows 10.
here's code snippet:
dim myxlapplication, myworkbook set myxlapplication = createobject("excel.application") myxlapplication.visible = false set myworkbook = myxlapplication.workbooks.open( emlattach ) myxlapplication.displayalerts = false myworkbook.application.run "main.main" myxlapplication.displayalerts = true myxlapplication.quit set myxlapplication = nothing
emlattach
set earlier in script absolute path , filename extension.
when executing via clicking on script file, works perfectly. when running scheduled task, or forcing run task scheduler, asks me program i'd use open file. if select excel, gives me error telling me file doesn't exist.
the file extension on error wrong, xlsx
vs qualified variable xlsb
.
executing .vbs task scheduler or login script (gpedit.msc ► user configuration ► windows settings ► scripts (logon/logoff)) require explicit reference overhead executable. wscript.exe windows based return or cscript.exe console based return. further, if .vbs associated default wscript.exe, may need specify cscript.exe running process in order avoid windows based return.
cscript.exe c:\<path vbs script file>\myscript.vbs
test command line @ cmd prompt. may need enclose folder names in quotes if contain spaces.
Comments
Post a Comment