Avatar of dearnemo
dearnemo
 asked on

SQL Job doesn't run vbs Script file

In reference to this thread: https://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_27727445.html#a37999278

Now I tried to run my vbs script from SQL Job. Though I get Job executed successfully, it didn't open up my excel file. I went to view the history for this job and found

Message
Executed as user: GSOPS4\SYSTEM. Microsoft (R) Windows Script Host Version 5.7  Copyright (C) Microsoft Corporation. All rights reserved.C:\WINDOWS\system32\TestTOPTMay307.vbs(5, 1) Microsoft Excel: Microsoft Excel cannot access the file '\\gsops4\data_extracts\TestTOPTMay307.xlsm'. There are several possible reasons:     The file name or path does not exist.   The file is being used by another program.   The workbook you are trying to save has the same name as a currently open workbook.  Process Exit Code 0.  The step succeeded.

Any thoughts?
Microsoft ExcelMicrosoft SQL Server 2008Visual Basic.NET

Avatar of undefined
Last Comment
ukerandi

8/22/2022 - Mon
ukerandi

try this
Under component services > Computers > My Computer > DCOM Config + Microsoft Excel application > properties > Identity Tab > Select the Interactive User > Ok.

 

You'll also what to add this to the bottom of your script so Excel closes and does not hang around in the background.

$excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel)

http://technet.microsoft.com/en-us/library/ff730962.aspx
ASKER CERTIFIED SOLUTION
ukerandi

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ukerandi

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23