Why not? What error is being reported? What is your service doing and what is causing the error?Quote:
the service installed fine but it won't start
Printable View
Why not? What error is being reported? What is your service doing and what is causing the error?Quote:
the service installed fine but it won't start
when i try start the service from the system control management the message error 2: system cannot find the file specified appears and when i run the batch file in the cmd i get the same message
All programs can be debugged, unless the program has anti-debugger features in it.
Second, even if you couldn't figure out how to debug, you always have OutputDebugString() and programs such as DebugView from sysinternal.com to see output messages.
Third, let's ask you to see if you understand what everyone is saying:
What do you think the result of this operation is?
?Code:CString path = GetExeFolderName() + TEXT("C:\\testService\\Debug\\testService.exe");
What string is going to be created from this?
Regards,
Paul McKenzie
i don't know. i thought that code just told the program where the exe file isQuote:
What string is going to be created from this?
i am using the code igor posted to this thread (post #42). the only line i changed was the path
Please post the code here that you are actually using.
ok i attached the code
Attachment 31371
How do you know that the service installed fine? Have you checked it with the services program? What does sc query MyServiceX say from the command line? What is the contents of the file mysvcx.log (not sure which folder it'll be in - do a search for it)?Quote:
the service installed fine but it won't start
i can see its installed because it appears in the Service Management Console list.Quote:
How do you know that the service installed fine?
C:\testService>if -u == goto UNINSTALLQuote:
What does sc query MyServiceX say from the command line?
C:\testService>sc create MyServiceX binPath= "C:\testService\mysvcx.exe"
[SC] CreateService FAILED 1073:
The specified service already exists.
C:\testService>sc start MyServiceX
[SC] StartService FAILED 2:
The system cannot find the file specified.
when i try run the service the file is empty but when i run the exe file it says:Quote:
What is the contents of the file mysvcx.log
[05/01/13 14:29:07] ++ Start ++
[05/01/13 14:29:14] -- Stop --
i don't have experience using batch files so i wasn't sure what to do.
i got this error:Quote:
run Visual Studio Command Prompt and run make.bat
test.cpp
test.cpp(1) : fatal error C1083: Cannot open include file: 'windows.h': No such
file or directory
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
10.cpp
10.cpp(2) : fatal error C1083: Cannot open include file: 'windows.h': No such fi
le or directory
what does sc qc MyServiceX show? Especially for the BINARY_PATH_NAME?
So basically you don't have any idea what that line of code does or what type of string will be created?
I don't know what you believe C++ is, but it isn't a scripting language or HTML. It requires that you know the language, and obviously you need to learn the language.
What does the "+" in red do? It joins two strings together to create a single string. It joins the string on the left with the string on the right to create a single string.Code:CString path = GetExeFolderName() + TEXT("C:\\testService\\Debug\\testService.exe");
What does the "=" in blue do? It assigns the value of the operation on the right hand side of the "=" to the variable on the left hand side of the "=". So "path" will contain the value of the concatenation of the two strings.
Now, look at the two strings you're joining -- you are taking the value of GetExeFolderName(), and adding to it C:\testService\Debug\testService.exe. So for arguments sake, let's say that GetExeFolderName() returns "C:\MyFolder\MyEXE\". So what is the result of "path" after the concatenation is done?
(extra slashes were removed for ease looking at the real value)Code:C:\MyFolder\MyEXE\C:\testService\Debug\testService.exe
Does that look like a valid directory name to you? Forget about C++, have you ever seen a directory name that looks like that? That name is not even a valid Windows directory name, regardless of what you want to do. If you want to be convinced, go to a command prompt and do a "DIR" on the name that "path" happens to be -- do you get back a listing or does the DIR give you an error?
That's why you keep getting the error and why you should have checked the result of "path" so that you know what you are using.
Regards,
Paul McKenzie