I am experiencing an issue with an application that is attempting to access Quickbooks in blind mode (i.e. Quickbooks is not running). In short, I have a simple C# application that synchronizes information between a Quickbooks company file and SQL database on a web server to allow customers to make payments toward invoices online. The UI for the application only has one button and a few other settings so, I modified the code so that it can be run as a scheduled task in the middle of the night. Unfortunately, this has been much more trouble than I anticipated.
First, I could not get it to run through the task scheduler or an elevated command prompt. Then, I came across a post that stated that there is a bug in the SDK when attempting to access Quickbooks via the QBSDK if the host is a terminal server with multiple sessions. The temporary solution was to make sure that Quickbook is running on the session that the job is running on to prevent it from trying to attach to another session. So, I made sure that Quickbooks is loaded but, NOT logged in to a company file. While this solution works if I try to run my application from an elevated command prompt it still does not work when the job is launched from the windows task scheduler. I am not logged into the server remotely now but, the error message states something about not being able to open a session because there is a modal dialog box open. I will modify the post to include the specific error message as soon as I am able to connect to my client's server. Quickbooks is open on the session that is trying to run as a scheduled task and I am able to run the application from an elevated command prompt. Can someone please offer any suggestions or feedback about how I might go about solving this problem? Thanks in advance for your help!
Related
I have a .Net application that's reporting hangs in the Event Log. The events say "Application Hang" with no usable details to go by.
So I whipped up a C# console app that uses the ClrMD library. But the caveat is this application is being published as a RemoteApp. When I try to attach ClrMD to the users' process I get this error:
Microsoft.Diagnostics.Runtime.ClrDiagnosticsException: Could not attach to process. Error 0.
This is not surprising since I'm logged into the server as Administrator and they are in their own RDP session with a different user.
So then I decided to impersonate the user they are logged in as thinking if I run my ClrMD app as them, it will have access to that process. This gave me a different error:
Microsoft.Diagnostics.Runtime.ClrDiagnosticsException: Could not attach to process. Error 1008.
I can't seem to find any clues as to what 1008 means to know where to go from here. I realize I'm probably trying to do something that's not possible.
Has anyone gotten ClrMD to attach to another user's process?
If not, are there are debug tools out there that can attach to other users' processes?
If not, have people used ClrMD in within production and how would I know the app is hung to know when to trigger a ClrMD dump? Just monitor the UI thread in another background thread?
Had / have same issue. Running elevated as admin on a server via a console app didn't work. But it does work if run through PowerShell or Visual Studio itself with elevated permissions. The debugger requires Admin privs to connect live. Adding a manifest, etc didn't seem to help when running as a console.
I have inherited a C# project (exe file) that needs to run once per hour. It ran on an old server just fine, but I don't have access to that server to view the settings. I have it setup to run as a windows task. The task runs but I'm getting the error:
System.Data.Entity exception the underlying provider failed on open - Login failed for user
SQL Server is setup for windows authentication. Websites that are running on the server which use Entity Framework connect just fine. The config file for this project is setup to authenticate the same (same setup as old server only thing I changed was the Data Source):
connection string="Data Source=WIN-FM8VFGOQQKN;
Initial Catalog=DatabaseNameHere;Integrated Security=True;
MultipleActiveResultSets=True""
providerName="System.Data.EntityClient
The Windows task is setup to run as a Windows login account that has access to this database. I am guessing simply setting up the Windows task to run the program as a Windows login account is not enough to authenticate?
EDIT to add info: When I run the exe file from the command line logged in as the same user who is the author of the scheduled task, it runs perfectly. It only throws a .NET exception when trying to logon to SQL Server when executed as a scheduled task.
I have searched around but all I can find are solutions related to web applications. This program is not running under IIS.
Env: SQL Server 2012, asp.net 4.0, C#, Windows Server 2012 r2
I wanted to go ahead and answer my own question as I couldn't find any other way around this issue. I had to change SQL Server to mixed mode authentication, create a database user, then change my connection string from windows authentication to SQL Server authentication. After that the task ran just fine. It's hard for me to believe there isn't a way around this, but I couldn't find anything. All other posts I found on the interwebs also stated they had to change to mixed mode authentication. What a waste of time!
Check if "run with highest privileges" in the scheduled task properties is set.
I am guessing simply setting up the Windows task to run the program as a Windows login account is not enough to authenticate?
A common problem of scheduled tasks are that the user account does not have "logon as batch" privilegs. It seems that this is not the problem here, since in the case of missing this privilege the task does not run at all.
But be aware that this privilege may be set via a GPO (group policy) from Active Directory, and this means that setting this privilege locally will be overwritten by the next GPO refresh.
And check the event log, normally problems with login / privileges missing will be logged.
I am trying to make a web service for my MVC C# app that will allow administrators to perform an iis reset by triggering a batch file with all the commands we use.
The website is hosted on a remote machine so this is not local. Security is in place for the web service to prevent this being triggered maliciously.
How would I go about doing this? I've tried
System.Diagnostics.Process.Start(#"c:\iisresetTest.bat");
This gave no errors, but it did not perform the reset.
I've also tried the directions here: http://labs.ratchet.com/566/running-command-line-bat-files-from-web-page-asp-net-c/
But that gave an error that I need to be an admin to run the command. I'm assuming the first line of code worked, but since it wasn't an admin it probably just closed down command prompt.
You can run a bat file as administrator using the scheduled task work around http://www.sevenforums.com/general-discussion/307201-how-run-batch-bat-flle-administrator.html I couldnt find the better page for that but you might find it googling. You can also go in the registry and turn UAC off but that could be dangerous.
I have written a Windows Service in C#. My service is meant to open an Excel macro-enabled workbook (this is in Excel 2010). I have installed this service on our server which is running Windows Server 2008 64-bit. My service seems to have a problem launching Excel when no one is logged on the server, does anyone have a solution to this?
I get the following error:
System.Runtime.InteropServices.COMException (0x8000401A): Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a.
Excel is installed on the server, the service works fine when I am logged on the server but once all users have logged off, I get the above error. I would like the service to launch my Excel workbook regardless of an open session on the server or not.
My service seems to have a problem launching Excel when no one is logged on the server, does anyone have a solution to this.
Of course it has a problem. Windows Services cannot show a user interface, so how would you expect it to launch a GUI application like Microsoft Excel when there is no user logged in?
The specific COM error code that you receive means:
8000401a: The server process could not be started because the configured identity is incorrect. Check the username and password.
In other words, Excel is trying to start as an interactive user, which refers to the user that is currently logged on directly to the server console. Since no user is logged on, no interactive user exists, and the application fails when it tries to assume this identity.
The design was broken anyway: Excel was not designed to be run from a Windows Service. Create a standard Windows application instead. If you need it to run in the background without a UI of its own, don't create a window.
Basically, Cody Gray's answer is right. In the past I had a need to launch Excel from a Windows Service in order to print the file.
We were able to get past that kind of errors by setting the service to run as a specific user account and from time to time, log on as that user account and try to launch the files that failed to see the error messages popped up by Excel.
In your case, it is possibly because Excel is started for the first time and it asks you for something like your initials.
Are you using Office Automation to start Excel? Sorry, but Office Automation is not supported in service processes. It is designed to work only in an interactive process.
If you're lucky, Using Office Automation from a service process won't work. If you're not lucky, it will appear to work, and you'll actually put your application into production. You'll then start finding random bugs which are very difficult to reproduce, and even more difficult to fix without breaking something else.
That will be due to the fact that the real bug is a design bug - you used Office Automation from a service process.
Take it from the Voice of Experience...
I have made a simple application in C# and WHITE, which click on a button to clear the logs.
I use to connect to my test machine using Remote Desktop Connection and execute that application. It works fine when my session is connected but whenever i disconnect my session, it stops working.
Is there any way to execute that application when windows session is disconnected?
You could write a Windows Service.
You could also use the task scheduler.
You may not need the C# wrapper, you can add yourself the required entry within the scheduler.
It works fine when my session is connected but whenever i disconnect my session, it stops working.
This is by design. When you disconnect your session, it is locked. When your session is locked, UI automation won't work.
You could hack around this by never locking the session, possibly via different remote desktop tools (VNC/PcAnywhere). But this is definitely a hack.
Instead I suggest a different approach. I recommend avoiding UI automation whenever possible. I have always found UI automation to be flaky and unreliable.
In the comments on your question you said your app is simply UI automation to click a button to clear a log. The logs are generated by the DebugView application.
I suggest you log to a file instead. This feature is mentioned on the web site for DebugView:
http://technet.microsoft.com/en-us/sysinternals/bb896647
You could also look into using remote monitoring.
If size is an issue, you can also look into the "Log file wrapping" and "log-file rollover" features.
Taken from
https://www.ranorex.com/help/latest/ranorex-remote/remote-faq#c13444
Create a batch file on your remote machine and insert the code below:
for /f "skip=1 tokens=3 usebackq" %%s in (
`query user %username%`
) do (
%windir%\System32\tscon.exe %%s /dest:console
)
Save this batch file on the desktop of your remote machine and name it: 'KeepSessionOpen.bat'.
If you need to disconnect the RDP session, you can now simply run this batch file using administrator privileges and your remote machine will remain unlocked.