Run .vbs with Task scheduler

Maggi Soffa
Maggi Soffa used Ask the Experts™
on
I am trying to run .vbs script who reads data from Excel. It works fine when I run it from command line but it does not work if I run it from Task Scheduler, but if I run it as Administrators  from Task scheduler it works. But the I can only save the task as "Run only when user is logged on"

file
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Does your script instantiate the "Excel.Application" object?
What exactly does not work? Any error messages?
Try to give to the user you are launching the script as the writing permissions to the following:
%SystemRoot%\System32\\config\systemprofile\Desktop   (create this folder if it does not exists)
 C:\Users\Default\AppData\Local\Microsoft
registry keys:
        ◦ HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft
        ◦ HKEY_USERS\.DEFAULT\Software\Microsoft

Also, do the following:
        1. run "mmc comexp.msc ",
        2. Expand Component Services/Computers/My Computer/DCOM Config/Microsoft Excel Application
        3. Open Properties, then switch to the "Security" tab
        4. In "Launch and Activation" panel switch the radio to Customize
        5. Click "Edit…" to open the "Launch and Activation Permission" dialog
        6. Add the user's accounts, then enable the “Local Activation” permission and save.

Author

Commented:
It has Set objExcel = CreateObject("Excel.Application")
There are no errors just stops but I can see in the Task Manager it opens Excel.
Try to use the Microsoft Sysinternals Process monitor tool to find out what events were failed.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
IIRC Excel (as all Office) tasks require a GUI session, and if running "whether logged on ..." there is no such session.
Maybe you can restrict the task to work with a CSV file instead, which does not require Office Automation.

Author

Commented:
I need  Excel to make the CSV/TEXT file automaticly therefrom another program process it.
Excel (as all Office) tasks require a GUI session
Not exactly. Please see my first comment which contains an instruction how to make the Excel work without a GUI session.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial