Solved

Windows service doesn't start

Posted on 2014-09-16
14
265 Views
Last Modified: 2014-09-23
Hi Experts,
I am having a C++ windows service (my own custom service), the installation of service (-i) works fine, however when I try to start the service using -s option, it gives me an error "Error 2: The system cannot find the file specified".
The GETLASTERROR API and its text does not tell me which file is it not able to find.
The same service works fine in debug mode (-d) option from visual studio.

On 3 other machines with the same set up, this service starts and works properly from service manager.
Can anyone of you help me identify because of which file is my service not starting? Also I have tried searching on Google (some site says it could VC re-distributable issues however I have verified them on other machines), also I have tried using dependency walker, even that has not helped.

Thanks in advance,
Karrtik
0
Comment
Question by:Karrtik Iyer
  • 8
  • 4
  • 2
14 Comments
 
LVL 2

Expert Comment

by:wackym
ID: 40325212
Hello Karrtik,

Which build have you run? Debug or release? Debug build uses "debug" runtime libraries which aren't present in any re-distributables.
Another issue might be PATH environment variable which could be different for services (depending on which user account is used to run the service).

Best regards,
Mike
0
 
LVL 15

Author Comment

by:Karrtik Iyer
ID: 40325235
Hi Mike,
I run Release Win32 build to install the service using -i option and then start using -s option.
While running from visual studio using -d option I use Debug Win32 option.
I am using Local system user to run the service.
I went and checked the dependencies (linker->input) of my service and all of them are present in PATH of the current logged in user.
Thanks,
Karrtik
0
 
LVL 2

Expert Comment

by:wackym
ID: 40325292
Hmm, if you check the registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\<your_service_name>\ do you have an entry ServiceDll or ImagePath? Do you also have a subkey "Parameters"? Does it have another ServiceDll or ImagePath value? (these take precedence over those in <your_service_name>)

Best regards,
Mike
0
 
LVL 15

Author Comment

by:Karrtik Iyer
ID: 40325318
Thanks Mike for this suggestion.
Well, I checked this and verified that :
1. It does not have a subkey "Parameters".
2. It does not have entry for ServiceDLL.
3. Yes it does have entry for ImagePath, and it is pointing to:
X:\ct\KBProj\develop\bin\rupscan\Tool\LMRemoteStatus.exe
which is the correct path and the exe is present at that path.

Regards,
Karrtik
0
 
LVL 2

Expert Comment

by:wackym
ID: 40325402
Hmm, you could try using procmon and recording the start of service...it should tell you which files the service tried to load and were unavailable or access was denied for them.

Best regards,
Mike
0
 
LVL 86

Expert Comment

by:jkr
ID: 40325408
Try Mark's Process Monitor (http://technet.microsoft.com/en-us/sysinternals/bb896645) with the filter set to your service's name to find out which file exactly cannot be located as a first step. Once you know which one can't be found, it should be easier to deduce the reason.
0
 
LVL 15

Author Comment

by:Karrtik Iyer
ID: 40325469
Thanks JKR and Mike, I downloaded the process monitor .
Just to understand if I am doing the right thing as per your suggestion.
1> I start the process monitor. In the search or Find option I set name of my service to find.
2> Start my service from windows service manager.
3> And see if anything gets listed in process monitor for that search.
Is this correct?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:jkr
ID: 40325491
Yes, pretty much like that.
0
 
LVL 15

Author Comment

by:Karrtik Iyer
ID: 40325556
Hi JKR, I just did that, and all the entries for my service in Proc Mon either shows SUCCESS or Name not found result. None of them had failures or access denied results, any help?
Thanks,
karrtik
0
 
LVL 2

Expert Comment

by:wackym
ID: 40325565
That's exactly it. "Name not found" means it tried to open/load a file which wasn't found. ...and in the same line it says which application tried to access the file and what's the files path.

Best regards,
Mike
0
 
LVL 15

Author Comment

by:Karrtik Iyer
ID: 40325929
Thanks Mike, I shall look into it tomorrow, however whatever little I saw of the name not found entries, they for the parameters that were passed as blank or null for the createservice, openservice, and startservice apis.
0
 
LVL 15

Author Comment

by:Karrtik Iyer
ID: 40328733
Hi Mike and JRK, None of the entries in Proc Mon suggested that something was missing or file was not been read or access denied. however i compared the proc man entries for the service on the machine where it runs fine as compared to the machine where it is giving error (System could not find the file specified). When I compared those entries, the below entries are present for my service where it runs successfully, however it is not present in the machine that errors out. All these DLL's are present in both the machines. I have pasted the information below. Anything that strikes either of you? I compared the system services running on both machines and both seem to be the same. Please advise and help. Thanks in advance.

apphelp.dll         Application Compatibility Client Library  Microsoft Corporation C:\Windows\SysWOW64\apphelp.dll
C_1252.NLS                                        C:\Windows\System32\C_1252.NLS
cryptsp.dll           Cryptographic Service Provider API          Microsoft Corporation   C:\Windows\SysWOW64\cryptsp.dll
dnsapi.dll             DNS Client API DLL           Microsoft Corporation   C:\Windows\SysWOW64\dnsapi.dll
mswsock.dll       Microsoft Windows Sockets 2.0 Service Provider               Microsoft Corporation                C:\Windows\SysWOW64\mswsock.dll
rsaenh.dll            Microsoft Enhanced Cryptographic Provider        Microsoft Corporation                C:\Windows\SysWOW64\rsaenh.dll
SortDefault.nls                                  C:\Windows\Globalization\Sorting\SortDefault.nls
wintrust.dll         Microsoft Trust Verification APIs               Microsoft Corporation   C:\Windows\SysWOW64\wintrust.dll
WSHTCPIP.DLL  Winsock2 Helper DLL (TL/IPv4)   Microsoft Corporation   C:\Windows\SysWOW64\WSHTCPIP.DLL
0
 
LVL 15

Accepted Solution

by:
Karrtik Iyer earned 0 total points
ID: 40330016
Hi Mike and JKR, I resolved this issue. Proc Mon could not help much.
The problem was that the service that I was running was on a virtual drive (mapped using VSUBST software http://www.ntwind.com/software/utilities/visual-subst.html).
Hence it was not starting. Once I moved it to a permanent drive (volume) it worked.

Thanks a lot for your inputs and suggestions.

Regards,
Karrtik
0
 
LVL 15

Author Closing Comment

by:Karrtik Iyer
ID: 40338643
No file access was denied nor registry entries were the issue. The issue was because of service being run from a virtual drive.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
why "." vs "->" 23 119
TCP/IP Socket - connection close results in data lost 14 120
Writing a parser for java language 4 71
c++ getting the first 10 characters of a char* string 11 90
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now