How to run a service as LocalSystem in Windows 7? - c++

I am trying to write my first service application following instructions in Windows SDK. I installed the service using the following code:
SC_HANDLE schs=CreateService(sch,
SERVICENAME,"VMFS - Servidor de arquivos",
SC_MANAGER_CREATE_SERVICE,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_AUTO_START,
SERVICE_ERROR_NORMAL,
pathexe,
NULL/*LoadOrderGroup*/,
NULL/*TagId*/,
NULL/*Dependencies*/,
NULL/*Account:Local System*/,
NULL/*Password*/);
The server does not start(error 1053).
But, if I go to services.msc and change service to logon as my account name (Valdeci), the service starts. So this seems to be a logon error. What is wrong? I want to run my service also in Windows XP and Vista, but didn´t try it because my developing machine has Windows 7.

Try using NULL instead of ".\\LocalSystem", as described in the CreateService documentation .

I solved my problem! I followed the tips I received: stripped the the code to a "do-nothing" service and it still didn´t work. So I concluded that the problem was not the code itself. The program didn´t even start because of "missing" DLLs. I discovered that "path" works differently when running as LocalSystem, so I copied all my runtime DLLs to the folder of the service. This is the way I normally install my programs, but at development time I use the path.
Thanks for your time!

Related

Cannot start server in coldfusion builder 2

I have installed Adobe ColdFusion builder 2 and was able to set it up, using this tutorial
http://www.adobe.com/devnet/coldfusion/articles/setup_dev.html
After I restarted my computer (for some updates to take effect), I am unable start the server I added using ColdFusion Builder (cfserver). I get the following error -
'starting cfusion' has encountered a problem
Ensure that the server is not already running, or another application is not using the WebServer port.
Does anyone know what to do about this? I am completely lost
EDIT: This is the error the console prints out
[cfusion]:07/13 12:50:14 Error [Thread-13] - Platform, Locale, and Platform Name must not be null
If you are using Vista or Windows 7 I used to have a problem with trying to start the ColdFusion server unless I launched CFB with Administrator privileges and ran it in XP Compatability mode.

Service wont start under Windows 7: FAILED 1053

I wrote a C++ service that functions perfectly under Windows XP but fails to start in Windows 7. SC CREATE returns success, however, SC START returns FAILED 1053: The service did not respond to the start or control request in a timely fashion. From what I understand this is caused by timeout, but I receive the error immediately.
Is this a problem with my service code or some setting in 7?
Does Windows 7 send service control requests differently then XP?
If so, how would I go about catching the start request?
Please let me know if you need to see the code as well as any other information that will help solve this problem.
Thanks
Solved Problem by installing MSVCR100D.dll into system32. No need to even change my code.

Fail to CoCreateInstance an EXE COM server

I have an EXE COM server (used to elevate our application to a higher integrity level) which is downloaded to %temp% and registered by an ActiveX control. This COM server works pretty well on Vista machines. On Window 7 machines I got something wired: the COM server can be downloaded and registered successfully, but I got the error 0x80080005 (Server execution failed ) when trying to initialize the server by CoCreateInstance. If I copy the COM server to %temp% manually instead of downloading it via internet then everything works as expected. I am suspecting that the downloaded EXE files have some special attributes that prevent it been loaded but have no idea how to figure it out.
Does anyone have the same experience or have any clue for this issue? Any suggests will be highly appreciated.
Joe
Yes they do. Start a command prompt and use DIR /R. You'll see the alternate data stream in the file. The one that says: "don't trust this file, it came from an untrusted source".
You can delete them with the filename:streamname syntax. Check if that's okay with your customer first. I don't know many that are thrilled about EXEs getting downloaded and bypassing normal security rulez.

Hudson build fails when a user logs out of RDP session

We are using Hudson to build mixed C++/Java projects with an Ant script. It is running in Tomcat 6, on a Win XP virtual machine.
I have noticed recently that when a user logs off the machine (from a remote desktop session), builds that are currently running tend to suddenly fail without an error message.
Has anyone encountered anything similar or have an idea what might be causing this effect? I can post additional information about our setup if needed, I'm just not sure what's relevant in this case.
EDIT: I have tried running the Tomcat service under various users, but this doesn't seem to help. Tried the standard Local System account, as well as the server Administrator and a domain administrator account.
Try adding -Xrs to the Tomcat JVM arguments.
For more information see this bug.

CruiseControl.NET run as a windows service and as a standalone process behaves differently

I have a project that is being built using CruiseControl.NET. The project contains an 'MSBuild task' that runs the build for the project and also the unit tests. The unit test in turn is just a MSBuild 'exec' task that runs an executable.
The unit test involves some .NET remoting. And when the unit tests are run through the system command prompt, the software's window opens up, tests run and the process exits.
When I force a build through the web dashboard, the build hangs at the point where the unit test starts running. The software's window does not open up, but the executable is running. If the process is killed through the task explorer, the build goes through with a 'Failure' status. This happens when I run ccnet as a windows service.
If I run CCNet directly (not as a windows service) and force a build through the web dashboard, the build and unit tests go through fine as expected. (with the window of the software opening up.)
It looks like there is a deadlock in the case where CCNet is run as a windows service. I am guessing it is related to the standard output/error streams.
Is this is known problem?
What might be the problem going on?
Any suggestions on debugging this?
How can I get around it?
(I am using CCNet version 1.4.4 SP1)
When CCNet is running as a service it is not going to have access to the display, so don't expect to see anything on the screen in this configuration. The first thing I would check is the permissions - make sure the service runs as an account that has permissions to access whatever resources you need. You also have CCNet log files, which you can find via Dashboard.
On a side note, try TeamCity instead of CCNet, its 10 years ahead.
Maybe this answer will help :
delphi windows service can't download file from internet
You should know that when running CCNet as an application (the dosbox) it uses the environment variables and all rights from the logged account. So it may connect to a server, use cached passwords, get registry variables for this account.
BUT when ran as a service, the account is the one you provided : LocalSystem for exampe, where env. varibales are not the same.
So, what you can do is to change the CCNet service account for test. Change it to your user account (with password), and I'm sure it will work better !