Excel automation through Windows Task Scheduler throwing an error - 80080005 Server execution failed - excel-2016

We have a console application to automate the excel data refresh everyday at a particular time of the day. It is working fine when we switch off the office updates. But when an office update happens, immediately this stops working and throwing this error:
"exception Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))."
But when we try to execute the same console application through command prompt, it is working fine and when the same is scheduled through SQL agent, then also it is working fine. Only the task that scheduled in the Task Scheduler is not working.
Workaround tried so far:
Set the Microsoft Excel Component's identity to "The Interactive user". This is working fine when a user is logged on to the server. So, this cannot be a permanent solution.
Tried to create the following folders in the windows directory.
"C:/Windows/System32/config/systemprofile/Desktop", "C:/Windows/SysWOW64/config/systemprofile/Desktop",
still it is not working.
I am using Microsoft Excel 2016 and the server is Windows Server 2016.
Any leads on this will be very helpful.

Related

Unable to create XLS file on web server

We have a WCF application on our web server. One of the service methods in this app creates an Excel XLS file with data and places the file in a directory so the user can down load the file later.
Our problem is that when this app attempts to create the Excel object, we get this error: Error in Create Excel Helper Workbook, and Application: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}
failed due to the following error: 8000401a The server process could not be started because the configured identity is incorrect. Check the username and password.
This is the line that causes the error:
using EX = Microsoft.Office.Interop.Excel;
EX.Application Application = new EX.Application(); //causes error
I did some research and what I have tried is to go into DCOMCNFG - Computers - My Computer - DCOM Config and Right clicked "Microsoft Excel previewer" - properties - Security, then added several groups and users to have Local Launch, Local Activation, etc....
But this did not help. Some of the articles say to choose "Microsoft Excel Application". However, I only see "Microsoft Excel previewer" in my DCOM Config.
Excel is installed on this server but we still have the above problem.
One strange thing is that if I remote into the server, then have my client(browser) on my PC call the service method to create the XLS, this works without a problem.
What do I have to do to resolve this issue?
You can attempt to make this work by setting the IIS AppPool Identity to a user that has interactive logon rights. The interop assemblies actually work by launching an Excel instance on the server and then communicating with it to perform work.
That being said, having gone down this road before, it is a poor solution. The challenges you'll face are as follows:
Issues with DCOM permissions that are difficult to diagnose and resolve (you're running into this now)
Excel processes get spawned on the server and half the time do not close properly, so your application has to be smart enough to go around killing errant Excel processes, or living with the fact that your application is going to leak memory like crazy
It isn't supported or recommended by Microsoft
Office wasn't designed with server-side security considerations in mind
See the following for additional details:
https://support.microsoft.com/en-us/kb/257757

Copy database fails with SQL Agent not started error, but it is running

I'm trying to copy a database to another server. I've successfully done this with these two servers several times, the last time was just a few days ago. However, now when I try to execute it, I get an error:
TITLE: Copy Database Wizard
------------------------------
Start failed for Job 'CDW_xxxx_SGSTG51DBA01_13_2'.
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch
(Microsoft.SqlServer.ConnectionInfo)
------------------------------
SQLServerAgent is not currently running so it cannot be notified of this action.
(Microsoft SQL Server, Error: 22022)
Base on this information, I immediately checked that SQL Agent was running. It wasn't, so I started it. I ran it again, but got the same error. I then double checked that the login information provided for both the source and destination servers was correct. It was.
So I'm now getting this error with verified connection information and SQL agent is running. What else could be causing this problem? Does the account running SQL agent need access to both servers?

Sharepoint URL not able to acess through SQL agent Job

I am running a sql server job which is loading data from a file kept in a sharepoint document library.File is an excel format and is getting loaded when executed through solution .But when i am using an SQL Agent job to pick up the file it doesnt get the path and agent job fails.I have deployed the SSIS Package through SQL Server 2012 deployment methodologies.I am not able to trace the error of loading data from a sharepoint library.library. Sql agent jobs works fine when i give local path.The account which is running the sql agent job is the same who has access to document library.I also tried to run the job through proxy but then a strange error comes of error authenticating proxy:unknown username and password whereas my password and username are all correct.I am in between of my deployment to production and facing such issue from a long time.

Cannot start LocalDB

Cannot start LocalDB instance, I have installed and re-installed over and over.
Keep getting this error :
Start of LocalDB instance "v11.0" failed because of the following error:
Error occurred during LocalDB instance startup: SQL Server process failed to start.
Anyone any advice ? ?
Microsoft SQL Server 2012, i have ensured the FULL installation options, stopped all services SQL related and tried restarting .
sqllocaldb info
gives me :
Projects
v11.0
when i try
sqllocaldb start v11.0
I get the above error.
When all else fails and you don't care about data loss, delete and recreate your LocalDB\v11.0 database! At the command prompt
sqllocaldb delete v11.0
sqllocaldb create v11.0
(Sqllocaldb is in your PATH right? It was for me.)
I was getting a similar error, but when running
sqllocaldb start
The local db started successfully. Also when checking the event log I saw an error along the lines of
Windows API call WaitForMultipleObjects returned error code: 575
What fixed it for me:
In IIS, configure the app pool to run under an account with permissions to the DB on the server (advanced options of the app pool)
In the advanced option of the app pool, set Load User Profile to true
Reference: http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-1-user-profile.aspx
It worths looking at LocalDB log files too, it is more detailed than event log:
%LocalAppData%\Microsoft\Microsoft SQL Server Local DB\Instances\ProjectsV12\error.log
Besides recreating the instance I had to delete the content of this folder:
%LocalAppData%\Microsoft\VisualStudio\SSDT\
This is where I have the mdf and ldf files.
My solution:
Go to: %LocalAppData%\Microsoft\Microsoft SQL Server Local DB\ and allow total control of the folder "Instances" to everyone group.
I know this is not OK but it solved my problem and i don't really care about the data of that folder as this is a developing and testing computer.
Same problem here. Here's how I fixed it using bits of the other solutions posted here.
I had dozens of these errors in the application event log:
Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3730.
I realized that I had SQL Server Management Studio installed on my development machine, but no other SQL components. I installed the database engine, shared components, and localdb from SQL Express
https://www.microsoft.com/en-us/cloud-platform/sql-server-editions-express
After installing, I still get the same error in event log :(
Found this article:
Cannot start LocalDB
Run the following in cmd to get the localdb instance name:
C:> sqllocaldb info
In my install, I had:
MSSQLLocalDB
ProjectsV13
I ran the following to delete the instances:
sqllocaldb delete MSSQLLocalDB
sqllocaldb delete ProjectsV13
I ran into issues trying to delete/create these (sqllocaldb delete MSSQLLocalDB). I ended up deleting all of the folders and files under '%LocalAppData%\Microsoft\Microsoft SQL Server Local DB\Instances*' (You need to stop SQL Server and kill all sqlserver processes)
Then running 'sqllocaldb create' created and started the default instance and all files.
Had this issue suddenly too but saw nothing weird in logs. Was able to get it running by running the following in an administrator command prompt:
sqllocaldb start
I had this issue. I was trying to use Windows Authentication through an application, but the IIS App Pool credentials were wrong. I was using my Windows user name (ie: NETWORK\name) as my identity, but I changed it to the built-in "LocalSystem" and it worked.
You should check the Event Log for additional information.
Product Name
SQL Server
Product Version
11.0
Product Build Number
Event ID
266
Event Source
SQL Server Local Database Runtime 11.0
Component
Local Database Runtime API
Message Text
Error occurred during Local Database instance startup: SQL Server
process failed to start.
Explanation
A SQL Server process is started but SQL Server startup failed.
User Action
See the event log for details.
Source: http://msdn.microsoft.com/en-us/library/hh256140.aspx
What worked for me was the local IIS application pool I was using was the ApplicationPoolIdentity and that did not have permission to login to MSSQLLocalDB. As soon as a I changed the app pool identity to my windows login account - I was able to connect ok.
Had this issue on Windows 10 when our application was run with compatibility for Windows 8 enabled. Turning off the compatibility setting fixed it.
Before you try something drastic:
After waiting for about 5 minutes it "healed" itself.
(May be this is what this log message is pointing at: "The RANU instance is terminating in response to its internal time out")
I can not yet comment posts here but I really want to give a hint for the in my case extremely helpful post https://stackoverflow.com/a/30298863/8015089 above:
If your LocalDB instance is run by the Windows SYSTEM user (as in my case) the path to error.log is this (MS SQL Server 2012 Express LocalDB on Win11): C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\<InstanceName> (enter this path subfolder by subfolder to avoid access problems!)

Differences in execution of console application directly from .exe vs executed via task schedule?

im working on a Window server 2008, in this server i developed a vb.net 2008 console application that open a excel 2003 file and use its contents to create a xml file, so i have two situations:
1. Differences in execution of the program: if i run the application from the Visual Studio or directly from the executable it open and process the excel without problems but if i configured a task on the windows task scheduler or in the adtempus that execute this program its failed and throws this exception:
Exception from HRESULT: 0x800A03EC- at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
at .Module1.convertExcelToXmlFile(String excelFile)
i have read alot about this exception, but at the moment im unable to resolved, so I want to know how this program can execute correctly from Visual Studio or directly from the execute but failed when its execute on a task if both situations are in the same server? is there a way to fix this behavior?
2. In the console application when i open the excel file with the open method, the file in excel appears for a few seconds then it closed, is there a way to access the excel file contents but that the file dont show in Ms Excel?
thanks.
You should not be using Office Interop in an unattended process.
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.
http://support.microsoft.com/?id=257757
There are a number of products that will manipulate Excel docs and run correctly unattended.
Is the Excel file you're trying to open on the network?
If so, the problem is most likely because your Task Scheduler service and any jobs it runs are (by default) running under the local SYSTEM account, which is prohibited from network access.
If you change the task to run under a different account (say, for example, a domain account that you have given privileges for the remote fileshare). (Note that this change may effect how other scheduled tasks run, so you'll want to be quite sure of the permissions needed.)
Just in case you have not figured it out yet, the most-likely resolution which worked for me can be found at this URL :
https://social.msdn.microsoft.com/Forums/en-US/b81a3c4e-62db-488b-af06-44421818ef91/excel-2007-automation-on-top-of-a-windows-server-2008-x64?forum=innovateonoffice
If your server is a 64-bit one, create a folder named 'Desktop' in the below mentioned path i.e. C:\Windows\SysWOW64\config\systemprofile\Desktop
If your server is a 32-bit one, please make this folder C:\Windows\System32\config\systemprofile\Desktop