Please Help! My windows service has permissions problems running a macro in an Excel spreadsheet.
I have a macro in an Excel spreadsheet that connects to an OPC server to retrieve data. I works just fine when I run it manually, or when I run it programmatically from a standard windows program. But when I try to do it from a service (running the same code as the standard windows program), it fails.
If I run the service from the Local System account, it opens the spreadsheet but completely loses track of the Excel object and cannot close it. If I then check "Allow service to interact with Desktop", it opens the spreadsheet and runs the macro, but the macro then doesn't have permission to access the OPC server. If I run the service from the Administrator account, the service does nothing - no event log entries or anything. Can someone PLEASE help me quickly with this?
Status:
Open Nov 27, 2007 - 08:48 AM
servers, .net, windows
10answers
Answers
Nov 27, 2007 - 08:55 AM
what happens when you run the service from a local admin account?
Nov 27, 2007 - 09:06 AM
what makes sense is that your service is running the account with local system privilages, yet the current user is the account with permission to access the OPC server, if this is a domain environment, create a user account with permission to access the opc server. then on the workstation, right click on "my computer" and find the manage user's button. change that user to a local aministrator. now configure your service to use that username and password and you should be golden.
Nov 27, 2007 - 09:14 AM
This is a system with no network connection except to the DCS system (fancy PLCs). It is running the DeltaV HMI, and I am trying ot connect to the DeltaV OPC server. It is running on the Administrator account or the Local System account, whichever one I set it to, with the (broken) functionality I described above.
It is not a domain environment.
I can't understand why, when it is running on the Administrator account, it does absolutely nothing - not even logging to the event log. I have lots of events being written in the code, but none of them are being written. Does this help explain the problem better? I am already trying to run it on the Administrator account, and it does even less than when running on the Local System account.
Nov 27, 2007 - 11:21 AM
try using the logon:
NT AUTHORITY\NetworkService
as the username for the service or better yet, use the username you are currently logged in as.
what I'm thinking is that the windows isn't allowing multiple logins to the opc server, (windows does this especially with shared folders) if you have any mapped drives, you might want to temporarily disconnect them also. what you want to do is make sure the service is using the same logon credentials that you're using when you log in to the computer.
Nov 27, 2007 - 11:23 AM
you can view current credentials to network resources by typing in
net use
into the command prompt.
Nov 27, 2007 - 01:10 PM
Thanks - Sorry for the delay. I did not have access to the internet again until just now. I did use the username I was logged in as - Administrator. That was the case where nothing happened at all with the service. There are no mapped drives, and the only thing networked is the DCS system. DeltaV may be the problem. At this point I don't know what else it could be. I left a non-service band-aid solution in place. When I can go back (to the client site) I will play with the net use command to see if I can see anything out of whack. Thanks for trying.
Nov 27, 2007 - 01:10 PM
I will get back to this, but it may be a couple of weeks.
Nov 28, 2007 - 05:59 AM
the non-service band aid may have to be a more permanent solution. I read somewhere that services and macros don't go well together. if I find the article again I'll post it. is there a VB script approach that you might be able to use?
Nov 28, 2007 - 06:45 AM
I would be very interested in that article if you can find it. The thing is, my service runs just fine with the test macros I used, so it must be an authentication problem when run on the Local System. I just don't understand why it does absolutely nothing when I run it on the Administrator account.
Mar 04, 2009 - 06:02 AM
The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.
The Quomon Team
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment