Windows service properties - log on - c++

so i was following this tutorial http://code.msdn.microsoft.com/windowsdesktop/CppWindowsService-cacf4948
and i was having problems starting the service in the Service Management Console. I was getting the error message 'windows cannot start the service on local computer error 5 access is denied'
but i found that in the properties of the service i'm trying to start if i go to Log On tab and click Local System account instead of this account it works.
I just want to know what actually happened here? and does it affect the service in any way?

You have changed the account that is running the service. This may have a lot of implications most importantly involving permissions. It is always important from security standpoint to limit the permissions a service has.
Also a user needs to have some permissions to be able to run a service(for instance Log on as a service). These can be set in Local Security Policy->User Rights Assignment(this may vary depending on the windows you are running on). The user you try to run the service with seems not to have enough permissions to run your service. Try to investigate why is that.

Related

Debugging Windows service failure before main() (error 1053 when run by LocalSystem user)

I have a Windows service that works perfectly when run via a user account, but fails with error 1053 when run by the Local System account. Unfortunately, whatever is going wrong happens before my main() function is called, which means I can't even insert logging calls to track down where things go wrong.
How can I debug Windows service startup failures when it's happening in pre-main() code?
Any ideas why it might fail specifically when it's run by the Local System user?
NOTE: Not sure if it's relevant, but I'm compiling with GCC, and the code depends on Cygwin.
This won't be complete answer because without actually having event log it would not be possible.
Since this happens pre-main this would be related to what your user account can do and what local system cannot.
In service property panel, for Local System account you have "Allow Service To interact with desktop". Many times this can be the reason.
The other of course is, your service is loading some libraries which are off limits to it - because of network\group security (local system cannot access network so far as I know).
You will need to eliminate one piece at time to see what happens. Or other way round - make service empty remove all dependencies and play 20 questions.

My SSH session into my VM Cloud is suddenly lagging

Everyday I log into my SSH session of a Google Cloud VM I maintain (Debian).
Since a week ago, I noticed my performance was lagging as I typed into the VM or when doing something else. I mostly login into this VM to check log files of scheduled scripts I have, and even when I use "cat script.log", what used to take less than 2 seconds now takes at least 5 or 7 seconds, loading the log text.
Pinging different websites bring me an reasonable 10 - 15 ms. I'm pretty sure it's not about my local connection either, everything else I do works fine in my local computer.
A warning started to appear now into my session, saying
"Please consider adding the IAP-secured Tunnel User IAM role to start using Cloud IAP for TCP forwarding for better performance. Learn more Dismiss"
I've already configured the IAP secured tunnel to my account, which is the owner account of GCP project.
Another coworker of mine is being able to access the VM without any performance issues whatsoever.
Your issue is in my opinion with the ISP. For some reason the SSH sessions are lagging.
That's why even other computers using your home ISP lag SSH sessions too. If that was firewall rule interfering you wouldn't be able to connect at all.
You may try to reset all the network hardware in your home and if that doesn't help
run tracert command in windows shell and then contact your ISP and pass your findings. It's possible it's something on their end (and if not maybe their's ISP etc).
To solve the problem you need to add "IAP-secured Tunnel User" at the project level in IAM for that user.IAP-secured Tunnel User + See instructions here in a blog I wrote about this. That should solve your problem.

When running as a windows service, how do i get the number of active monitors? C++

I have ran into an issue when retrieving the number of active monitors while the exe is running as a windows service. I have tried using EnumDisplayDevices and GetSystemMetrics(SM_CMONITROS) to get the number of monitors, these two methods woulds give me the correct number of monitors when running them as console mode (meaning initiated by the user), but when I register the exe as a service and run it through the windows service, the number of monitors that was reported turned out to be incorrect.
Is there any other way to determine the number of active monitors while running as a windows service? Or any other work around? Thanks in advance!
Services are not allowed to interact with the user desktop for security reason. Therefore they are running in their virtual desktop which has nothing to do with the physical one. You can try the following. In the service list of the service manager. Rightclick your service, go to properties and there to "Log On". There you can change the account the service is using. With the "Local System account" you can check the "Allow service to interact with desktop". I didn't try that my self. But for interacting the service has to get the access to the "real" desktop and therefore the monitor count should be right.

Windows Permissions/Policy required to use qWAVE

I'm attempting to use qWAVE (on Windows Server 2008 R2) to set arbitrary DSCP values on socket traffic. I think I'm setting up the flow correctly, but when I try to call QOSSetFlow(), I'm getting an ERROR_ACCESS_DENIED error ("The calling application does not have sufficient privileges for the requested operation."). The user that's running this code is a member of the Administrators group, and I've looked through the various security policies but didn't see anything that looked relevant. Does anyone know what permission I need to give the user to get this API to work?
Thanks!
UPDATE: I've got a test program that just tries to set the DSCP values, and when I check "Run as Administrator" under the Compatibility menu everything works fine. So the code is okay, and the Administrator User has the necessary permissions. Unfortunately the actual service can't be run as the Administrator User. Is there a way to give the Administrators Group (or a specific user) some of the permissions that the Administrator User has?

start service with out invoking uac

I have noticed some applications (like steam) are able to start/stop services as a normal user with out invoking the uac control. Does any one know how to do it?
OS: Vista/Win 7
Visual Studio 2005
C++
.
Edit: I was playing around with the steam service last night trying to work out how it is different. If i put my service exe where the steam one is it launched it fine with out uac (using sc.exe) but if i used the steam exe where mine is it didnt work. Looking around in the registry at the service information i found the steam one had an extra permissions part to it. What does this mean and how do you set it?
.
Edit 2: You need to change the user access rights of the service: http://msdn.microsoft.com/en-us/library/ms684215(VS.85).aspx
The ability to start (or stop) a service is controlled by the ACL on the service. If you grant interactive users the right to start your service, they can start your service.
It's all in how you set your service up when you installed it.
Obviously you'll have to use the Windows service APIs (OpenSCManager/OpenService/StartService) to start the service.