Command line application running as a windows service. Getting error 1053 - c++

I have created a c++ command line application. This application sends a revives messages from other computers and logs the results to a file. A simple application. One of the first things the app does is write to the log file the start up time.
Now that I have gotten the application to a good place, I want to install it as a service that runs on my computer (win 7).
I am using the NSIS, Simple_Service_Plugin to install the application and register the service in windows. I can see the service in windows service manager.
When I attempt to start the service, I get the following error message. The log file does not get created.
Windows could not start __THE_APP__ service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
When I start the app from explore it starts without any problems and the log file is updated correctly.
When I search this error message on-line I find lots of help for C# and .Net applications and nothing for c++ apps.
My question is:
How do I start a C++ application (not dot.net) as a service?

A service isn't a regular appliction. It's a program that uses specific system classes and implements certain features that enable the OS to communicate with it.
See here (and the surrounding pages) for more details.

Related

ChromeOS errors in GCP Logging

I'm seeing errors in StackDriver logging for my Compute instance. The logs are showing repeated issues every hour, creating a lot of noise. I have a Spring Boot API deployed in a container to a VM in Compute Engine using latest stable version of Container OS.
I'm relatively new to GCP and don't understand what is causing this issue, searches have come up empty so far.
Failed to call method: org.chromium.SessionManagerInterface.RetrieveActiveSessions: object_path= /org/chromium/SessionManager: org.freedesktop.DBus.Error.ServiceUnknown: The name org.chromium.SessionManager was not provided by any .service files
CallMethodAndBlockWithTimeout(...): Domain=dbus, Code=org.freedesktop.DBus.Error.ServiceUnknown, Message=The name org.chromium.SessionManager was not provided by any .service file
Error calling D-Bus proxy call to interface '/org/chromium/SessionManager': The name org.chromium.SessionManager was not provided by any .service files
The same 3 lines are repeating every hour. Anyone aware of what might be causing this or how to fix/suppress these?
I looked into this error, and as per my findings:
The error message that you have been receiving is a manifestation of Chrome to reliably exit shortly after starting up.
The UI’s job (which encompasses Chrome, the session_manager and the window manager) gets shut down by upstart because of it's thrashing, and when the test tries to restart the session_manager, the session_manager cannot communicate it over to the D-Bus.
The crash collection software in Container OS was originally for Chromebooks (The laptop using Chrome browser). So the code typically expects Chrome and some other related software on the system.
However, Container OS is a server OS, and does not have Chrome. So if Chrome is missing, the software will report some errors. They are actually not real failures, just some verbose error messages.
Overall, It is safe to ignore these logs and continue using your VM Instances.
Hope this helps.

cloud sql proxy as a service on windows 7

Run "cloud_sql_proxy" as a service in "windows 7" operating system
I have the binary "cloud_sql_proxy" with which I can access the instance of the mysql server in the Google cloud platform, up there all right.
but I need to ensure that the executable provided by Google, is always running and so my application / client program does not lose the link to these services.
Any idea how I can do this?
Based on what I understand from your question, it seems you are attempting to ask “ How can I run cloud_sql_proxy_xXX.exe when I startup Windows 7 ?”. I can tell you that the proxy does not run as a service so you will have to execute it every time you boot up your machine. Luckily, running programs on startup for Windows 7 is relatively easier than later versions of Windows such as 8.X and above.
For Windows 7, You can follow the guided steps provided here. Essentially, you just have to put the .exe file you wish to run in your Startup folder under the Start menu. (I.e: Open Start menu > All Programs > Startup > Drag file in here)
This should execute ”cloud_sql_proxy_xXX.exe” every-time you boot your Windows 7 local machine.
The documentation for GCP says literally:
"For the Windows operating system, run the proxy as a Windows Service. In general, the proxy should have the same uptime requirements as your application process."
so your answer is not acceptable.

Windows program doesn't run when started using sc create

I have created a program which is supposed to run as Windows service, starting automatically on boot.
Also i have created a starter, which should create a service and then stop.
Starter is ran as administrator.
I call this system command from a starter:
system("sc create MyApp binpath= /*full path*/ type= own start= auto DisplayName= MyService");
system("sc start MyApp");
Then Windows says that service creation successful.
However, the program which should run as service just doesn't start!
After the "sc start" command the console shows nothing for a while, Task Manager shows "Starting", and later console says
"Error 1053: The service did not respond to the start or control request in a timely fashion".
I tried running a command like this, showed in another post here on StackOverflow:
sc create SERVICENAME binPath= "**cmd /c** c:\programlocation\program.exe"
However, then it says:
StartService Failed 2: The system cannot find the file specified.
So the **cmd /c** thingy doesnt work.
How to make it work, and please only Windows native tools, no external programs.
You could do something like this:
Native C++ Windows Service
But I'd switch to C++/CLI and port the following code examples from C#:
System.ServiceProcess.ServiceProcessInstaller
Or, even better yet, just do the Windows Service part of your code in C# ... it's much easier than rolling your own in C++.

How do I find out why I am getting an EOSError code 5 - Access Denied registering a service?

I am getting an EOSError code 5 - Access Denied when the
TServiceApplication attempts to register the service with the
ServiceManager.
I am using XE2 Win7 64 bit. The error occurs for both 32 and 64 bit
targets.
I have a datamodule that uses ADO to connect to a database, and the web
services server code. All the code is used in a WinUI project which
works. I also have an untested ISAPI DLL based on the same core code.
This is the first time I have tried incorporating a Web Services Server
into an NT Service.
I have traced the VCL code that produces the error at line 1027 of
Vcl.SvcMgr but I don't know why I am getting the Access Denied error. I
have written other NT Services that connect to the database through ADO
and have not encountered such an error (although written with XE).
Any pointers would be appreciated.
You are likely encountering a UAC permissions issue that expects you to run the service install process in an elevated state, such as from a cmd.exe instance that was launched via the "Run as administrator" option, but you are not actually doing so. If you are having this problem with only some services and not others, then the affected services likely do not contain a UAC manifest but contain characteristics that are triggering UAC's Installer Detection feature, typically (but not restricted to) having reserved keywords in your service's filename or version resource.

Service Control Security Issues in XPCOM

I'm am developing a Firefox extension which interfaces with an underlying Windows service (which I have already made).
During the development so far I encountered one bug in the installer program (which installs the FF extension AND the service). This was due to the security model on Vista requiring elevated privileges to be able to install and start the service. I adjusted the installer and now it installs fine (just with additional Vista'esque warning dialogs being displayed to end-users - which I can live with !)
I am now in the process of developing an XPCOM component that will install along with the XUL stuff I have already made. There will be a XUL javascript interface to the XPCOM which will try to do things like stop and start the service (e.g when user-configuration data is changed).
My question: Since FF will normally be run under a user account, will I run into any difficulties on Vista or other Windows flavors trying to start or stop my own service via XPCOM?
(When users run the installer I don't mind security dialogs popping up in Vista. But I certainly don't want this to happen whenever they try to change their info in the XUL interface.)
What is the correct way to go about this?
Yes, if your service is running as an Administrator then the Firefox process, running as a normal user will not be able to start or stop it. However, it appears that you can use the "sc" command to set access controls on your service from your installer, which means you can allow non-admin users to start and stop your service.
You'll need to use "sc sdset", which is documented (lightly) here:
http://technet.microsoft.com/en-us/library/cc742037%28WS.10%29.aspx
However, to use that, you'll need to read up on the "Security Descriptor Definition Language", which looks kind of complicated:
http://msdn.microsoft.com/en-us/library/aa379567%28VS.85%29.aspx
This blog entry appears to have some human-readable information on it:
http://blogs.dirteam.com/blogs/jorge/archive/2008/03/26/parsing-sddl-strings.aspx