I have a test gui(winform) which I use to test my wcf service. The service callĀ“s another project in my solution which uses some windows api methods(user32.dll) to find word dialog boxes. It works fine when I test it locally, but when I setup my wcf service in the iis and test it with soapUI, it fails to retrieve and do the desired action on the word dialog boxes.
I suspect that because I am using a winform to test the service, so when I run the test form the solution creates instances/handlers so the windows/dialogboxes are at my disposal in the solution. Testing the service alone without creating the test winform does not make the service get the dialogboxes...
Could this be a permission issue in the iss or somewhere else? I have tried to grant the worker process admin rights, but maby I am not granting the rights in the wrong place. I need find out how the service alone can get a hold of the windows/dialogboxes with user32.dll methods?
windows 7 pro, iis7, vs2010
Any help is greatly appreciated.
Your approach is completely wrong. It works under Visual Studio because it's runing under your user account, but once deployed in IIS, it runs in the context of the App Pool account, which has limited rights and can't interact with Desktop.
Even if you run the service under an Admin account, which is a big security flaw, it will only work with local windows, never with windows on remote machines.
If you explain better your requirements maybe we could suggest a better approach for this.
Related
I'm trying to run an exe with parameters from a web application.
I'm using Process.start() but it does not seem to run on iis!
It works fine when running from iis express. I'm publishing the application to my local iis as a test but it does nothing.
I've tried setting the iis admin service to enable interactions with the desktop and ive told iis to connect as my user credentials and set the application pool to use the same user credentials but still nothing works!
is there anything else someone can advise to get this working!
Cheers.
UPDATE
I got iis to run the process by setting the application pool identity to local system and double checking the credentials for the site.
But as expected the applications do not interact with the desktop, so creating a file from command line is simple, but running an application with parameters do not have the application open.
At the moment iis admin service has interact with desktop checked and is using the local system account.
Ok so this isn't really an answer but in the end I got process.start to work by setting the application pool identity to local system.
But as expected the commands do not interact with the desktop, but this was enough for what my application needs to do.
Sorry for the poor answer.
I read some topics here, but I haven't found the solution of my problem.
I wrote application(C#, WPF, EF, sql server compact) that should start at windows startup. I tried to achieve that in two ways:
Add entry to windows register. Unfortunately that wasn't work on Windows 7. I found here that adding a shortcut to Startup folder can solve my problem...
I've added shortcut to my application in Startup folder. Unfortunately again it is not working...
My application is starting with admin permissions because is using external dll's sql server compact. Maybe this is reason? In addition my application is not signed and probably will not be. Also writing a wcf service could be bad idea in my application.
Do you have any suggestions, or solutions for that problem?
It's against windows guidelines ( and enforced by the operating system ) to put a program that requires UAC elevation in the startup process. It's a horrible user experience to be prompted for elevation every time they logon to a computer.
I would factor the wcf / sql into a service and keep the client side UI elevation free.
Reference: Error message when you start a Windows Vista-based computer: "Windows has blocked some startup programs"
The solution for that problem was to make user to install sql server compact on his own computer instead of embeding it in application folder and change permissions for application to asInvoker from admin.
We are using the ServiceController object to query if our Service is running or not. Our web application that is performing the query is using Impersonation for security/login.
System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController("myService");
return sc.Status
Using an Administrator account, the query is successful. Using a limited account (non-administrator), the query is failing with a message of "Service myService was not found on computer '.'"... BUT it is only failing in Windows Server 2003 and not in Windows XP.
I've Googled it and checked in MSDN. I didn't find anything related to the usage of ServiceController in Windows Server 2003.
Any ideas?
EDIT: If there is a way to query the service status without using the ServiceController that doesn't involve "security" privileges, that might work for us. We just need to get the status of the service.
UPDATE:
I created a simple console application that will print the status of the service. I used the "runas" command to run the application using both the Administrator and Non-Administrator account. It both worked in Windows Server 2003... Which means that this is an issue of the privilege not being properly passed to the ServiceController call in the web application? IIS security stuff perhaps?
Thanks!
I thought that web app-s are supposed to be run in a sandbox. Allowing access to the service running on local computer isn't really what you should do, because of security issues.
Maybe you could tell us what you want to do and there is another solution?
I have a Windows service which I want to periodically execute an external program. I'm currently doing this the usual way
Process program = Process.Start(#"C:\mpewatch\db_parameters\DBParameters.exe");
This doesn't seem to be working. I'm executing this from a separate thread which is started in my service's OnStart handler. Is there any conceptual problem with this? Is it not possible to execute external programs from a service like this?
You can execute external programs from a service, but there are security issues. For example, your service may be running under an account which does not have read access to the folder where the external program resides, even if your interactive account does have that access.
For test purposes, try to configure the service to run under your interactive account. If the program is invoked as expected, then the problem with the original account is that it does not have sufficient privileges to run the program.
Your question didn't indicate the operating system.
On Windows XP, you can configure your Windows service to interact with the desktop by opening the service control panel, double-clicking your service, selecting the Log On tab, configuring the service to run as local system, and checking the checkbox. It's pretty straightforward. You might try testing with something like Notepad.exe just to see if you can get it working.
On Vista (and presumably Windows 7), however, you may be out of luck. I have read that the ability for Windows services to interact with the desktop has been removed in Vista. I forget what the terminology is, but basically services will run in "shell 0," whereas users will occupy "shell 1". User applications will be able to communicate with services and vice versa using technology like WCF, but services will not be able to communicate directly with the desktop. For example, any error boxes that pop up will have to be dealt with by swapping to "shell 0." Again, this is based on something I read a few months ago, and I haven't gone looking at it again. For me, I've structured my Windows service to be configured using WCF via a front-end app.
I'm sorry I don't have a link for you, but if your service will eventually have to migrate to a newer OS (or you are already there), this is something to check on.
Another critical consideration with Windows Services is that there is no GUI. Technically, there is an option to allow the service to interact with a local GUI, but you will not see it. This is due to services running as the Local System user.
Within a service, any modal dialog box (OK, Cancel, etc) is considered an error.
I'm looking for a c# snippet which I can insert in a Windows service. The code must empty the recycle bin for all users on the computer.
I have previously tried using SHEmptyRecycleBin (ref http://www.codeproject.com/KB/cs/Empty_Recycle_Bin.aspx) however the code doesn't work when ran from a windows service as the service is running with local system privileges.
Hopefully you can't.
A service running as the local machine should not be clearing my Recycle bin, ever.
You could promote the service to run as an Admin account then it would have the right (and be a security risk), but why do you want to do this? It sounds like the sort of think Viruses try to do.
I think doing something like this is against Microsoft recommended practices. What are you trying to do that requires emptying the Recycle Bin from a Windows service?
First, have you tried running the service on an interactive user account? Maybe SHEmptyRecycleBin requires an interactive user even though it doesn't necessarily display a Window.
Second, I'm not sure it's a good idea to delete other users' stuff but I guess you have a very good reason?