Windows service doesn't start

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
LVL 15
Karrtik IyerSoftware ArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wackymCommented:
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
Karrtik IyerSoftware ArchitectAuthor Commented:
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
wackymCommented:
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Karrtik IyerSoftware ArchitectAuthor Commented:
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
wackymCommented:
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
jkrCommented:
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
Karrtik IyerSoftware ArchitectAuthor Commented:
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
jkrCommented:
Yes, pretty much like that.
0
Karrtik IyerSoftware ArchitectAuthor Commented:
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
wackymCommented:
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
Karrtik IyerSoftware ArchitectAuthor Commented:
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
Karrtik IyerSoftware ArchitectAuthor Commented:
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
Karrtik IyerSoftware ArchitectAuthor Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karrtik IyerSoftware ArchitectAuthor Commented:
No file access was denied nor registry entries were the issue. The issue was because of service being run from a virtual drive.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.