Windows service started and then stopped

Usually, I get this error: (The "service name" service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other service or programs) when there's

Usually, I get this error:
(The «service name» service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other service or programs) when there’s something wrong with my code, like non-existing drive paths, etc. The windows service will not start.

I have a windows service that backs up folder/files, to a location if it reached the size limit. Details are all provide by an XML Configuration that the windows service reads on start. I have a separate windows forms that has a button that does exactly what my windows service’s onstart is doing. I use my windows forms for debugging the code before I put it in my windows service.

When I start my windows forms. It does what it suppose to do. When I put my code in the windows service OnStart() method the error showed up.

Here’s my code:

protected override void OnStart(string[] args)
{

    private static string backupConfig = @"D:LogBackupConfigbackupconfig.xml";
    private static string serviceStat = @"D:LogBackupConfigStatus.txt";
    private static string fileFolderStat = @"D:LogBackupConfigFileFolderStat.txt";

    protected override void OnStart(string[] args)
    {
        if (File.Exists(backupConfig))
        {
            FileSystemWatcher watcher = new FileSystemWatcher();
            XmlTextReader reader = new XmlTextReader(backupConfig);

            XmlNodeType type;
            List<string> listFile = new List<string>();
            string fileWatch = "";

            //this loop is for reading XML elements and assigning to variables
            while (reader.Read())
            {
                type = reader.NodeType;
                if (type == XmlNodeType.Element)
                {
                    if (reader.Name == "File")
                    {
                        reader.Read();
                        fileWatch = reader.Value;
                    }
                    else if (reader.Name == "Folder")
                    {
                        reader.Read();
                        fileWatch = reader.Value;
                    }
                }
            }
            reader.Close();

            watcher.Path = fileWatch;
            watcher.Filter = "*.*";

            //this loop reads whether the service will watch a file/folder
            XmlTextReader reader1 = new XmlTextReader(backupConfig);
            while (reader1.Read())
            {
                type = reader1.NodeType;
                if (type == XmlNodeType.Element)
                {
                    if (reader1.Name == "File")
                    {
                        watcher.IncludeSubdirectories = false;
                        watcher.Changed += new FileSystemEventHandler(OnChangedFile);
                    }
                    else if (reader1.Name == "Folder")
                    {
                        watcher.IncludeSubdirectories = true;
                        watcher.Changed += new FileSystemEventHandler(OnChangedFolder);
                    }
                }
            }
            reader1.Close();

            watcher.EnableRaisingEvents = true;

        }
        else
        {
            StreamWriter sw = new StreamWriter(serviceStat, true);
            sw.WriteLine("File not found. Please start the Log Backup UI first.");
            sw.Close();
        }
    }

I don’t know what keeps the windows service not starting, the windows form simulator worked fine. What seems to be the problem?

UPDATE:
After many trials I’ve noticed that using only a folder directory (w/out file), the windows service doesn’t work. When I replaced the fileWatch variable with a specific file (including its directory), the windows service started. When I changed it back to a folder location, it didn’t work. What I think is that folder locations doesn’t work in a filewatcher.

When I tried creating a new windows service that watches a folder location, it worked.. However, when I tried the same location in my original windows service, it didn’t work! I was mindf$#*ed! It seems that I have to create a new windows service and build the installer everytime I place a new code/function.. This way I can keep track where I get an error.

  • Remove From My Forums
  • Question

  • I have a windows service and it was
    working fine, and today I tried to stop it and unlike the usual stop
    process, this one took a longer time. The next time I want to start the
    windows service, it raise an error that the service started and then
    stopped, it also said that service with no job stops automatically.
    When I checked the event log, there is no event about my service. My
    service worked well yesterday, in fact, it worked as usual just before
    I tried to stop it . but then I don’t know why the error appeared, I
    don’t think I did any changes to the database..

    Any solutions ? or if someone can share his/her own problem similar to this

    What my windows service do: read a log file, write to log file, then
    access database, then execute a stored procedure in 2 hours interval..

    Edit: I even tried to restart my computer after the problem keep
    happening when i try to start the service, but it doesn’t solve the
    problem.. now I cant start my service. One way I found to solve this
    problem is by re-installing the service. However, I need a better
    solution because I don’t want to keep re-installing the service if this
    problem appeared.

Answers

  • Solved that problem
    I cleared the event log, then it worked.. the application log was full so it couldn’t start..

Introduction:

Here I will explain how to solve the Service on local computer started and then stopped, some services stop automatically if there are not in use by other services or programs

The Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs.”

Now I will explain how to solve the Service on local computer started and then stopped, some services stop automatically if there are not in use by other services or programs.

To solve this problem we have two ways 

First Way

Start —> Run —> Type Services.msc and click enter button now you will get all the services in your computer after that select your service and right click on that and go to Properties

After that open Select Log On tab in that select Local System Account and click ok now your problem will solve

Otherwise check second way.

Second Way

First right click on My Computer and select Manage now computer management window will open

In that window select Application log and right click on it and select properties now another window will open in that change maximum log size to bigger value and check Overwrite events when needed

Protected by Copyscape Unique Content Checker

If you enjoyed this post, please support the blog below. It’s FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss
Subscribe by RSS

subscribe by email
Subscribe by Email

Summary

This Error Message Article explains the Windows error message “The [Service name] Service on Local Computer Started and Then Stopped. Some Services Stop Automatically If They Are Not in Use By Other Services or Programs” that sometimes appears with TEKLYNX software and details how to fix the underlying problem that caused it to appear.

Explanation

There are many reasons why a service would stop.  It is best to inspect the Event Viewer to determine the cause of the stoppage.  Possible reasons include:

  • Error within the application
  • License activation issue

Solution

Event Log should provide necessary information for the next steps.  The Windows Logs > Application log can provide general information about the behavior of different services.  However, in many cases, the software vendor will provide specific logs for their applications (see TEKLYNX example below).

Related Articles: KBA-01707-G3Z7K8: Modifying the MCLNet.ini Configuration File to Allow the Software to Run in Viewer Mode

KBA-01704-W6L2J1: MCL NET Service Fails to Start After Upgrading License

Issue Found: Microsoft Windows Server 2008 R2, running MCL NET v3

Eric Wolff

Eric Wolff has not written a bio yet36

Installation and uninstallation of a custom event source has a pretty complex logic, so it is quite easy to make a mistake is some scenarios. It’s hard to find out what was your problem without looking at your code; and it would be difficult for you to create a short code sample suitable for the post in your question yet manifesting the problem. Let’s try another way first.

I use some code to structure event logging per different application of the software product and shared a small wrapper which demonstrates right techniques. In particular, is shows how to setup and clean-up.
Please see my past answer here:

How to create event log under a folder[^].

I hope it will help you to see how to do it right. If you still cannot solve a problem, you will need to do a good for making the code sample I mentioned above. If you have some exception, don’t forget to dump it (in file), output Exception.Stack and all inner exceptions (recursively) and mark all relevant lines in your source code. By the way, chances are, when you do all these preparations you will clearly understand your problem by yourself and will be able to solve it.

—SA

Содержание

  1. The netlogon service on local computer started and then stopped. Some services stop automatically if they have no work to do
  2. Replies (4) 
  3. Windows service started and then stopped
  4. 2 Answers 2
  5. Windows service was started and then stopped
  6. Answered by:
  7. Question
  8. C# Windows Service — the service on local computer started and then stopped?
  9. 3 Answers 3
  10. The Windows Defender Service on Local Computer started and then stopped.
  11. Replies (6) 

The netlogon service on local computer started and then stopped. Some services stop automatically if they have no work to do

Thank you for posting your query on Microsoft Community. We are glad to assist you.

I would suggest you to try following the suggestions given below and check, if this helps you to fix the problem.

Method 1:

You may try checking if the problem persists in Safe Mode.

Step 1: Safe Mode with Networking

Boot the computer in Safe mode with Networking and check if the issue persists. Follow these steps to start the computer in safe mode.

Click the link and follow the steps “Start your computer in safe mode

If the problem does not exist in safe mode, try to perform a clean boot and check.

Step 2: Perform Clean Boot.

Putting your system in Clean Boot state helps in identifying if any third party applications or startup items are causing the issue.

Refer: How to perform a clean boot in Windows
http://support.microsoft.com/kb/929135

Note: After troubleshooting, refer to this section «How to reset the computer to start normally after clean boot troubleshooting»

Method 2: System File Checker.

You may run the system file checker tool and check if it helps. SFC scan will scan for the corrupted system files on the computer. You may refer to the following article in order to use System File Checker tool appropriately.

Use the System File Checker tool to repair missing or corrupted system files.

Do get back and let us know the status of the issue, we will be glad to help you further. We, at Microsoft strive towards excellence.

Windows service started and then stopped

I have created a windows application which runs fine and then i try to run this application as a windows service. After i start the service i got the error like below

Below are the error log i got from the EventViewerApplication

Faulting application name: MyApp.Client.exe, version: 1.0.0.0, time stamp: 0x50fce240 Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdaae Exception code: 0xe0434352 Fault offset: 0x00009617 Faulting process id: 0x1a7c Faulting application start time: 0x01cdf7a1dcc54dc3 Faulting application path: E:Email ServiceMobileMyServiceMainSourceClientServiceService1binReleaseMyApp.Client.exe Faulting module path: C:Windowssystem32KERNELBASE.dll Report Id: 2ef633e5-6395-11e2-8e41-e4115b2d2915

How can i resolve this error?

2 Answers 2

Its a very vague error. I can result from number of things and definitely not a code error.

  • Windows patch requires a restart. sfc /scannow on command prompt as admin.
  • The kernal.dll should normal exist on the location mentioned on the error else run the regsvr32 KERNELBASE.dll on command prompt as admin.
  • Restart your server.
  • Make sure correct framework is installed and any reference into your configs.
  • Correct service user if it was supposed to run with specific access or permission.
  • Make sure your application configuration is set to Any CPU to avoid 32bit and 64bit mismatch.
  • Make sure none of the system services are stuck in starting, if there are any easy thing to do is restart and validate or check your event logs to locate the specific issue

Ours was due to service user, wrong user was mapped which caused the issue.

I know this is an oldie but I was experiencing this issue and couldn’t find anything that was helpful so I hope this helps someone else!

The issue had to do with the sc create «YourServiceNameHere» command. When using this command you can supply the parameter type , providing the wrong value may be causing the issues.

When running the sc query «YourServiceNameHere» command, the result returned that the service was attempting to run using a shared process when it actually needed it’s own.

The resolution for me was to change my command from sc create «YourServiceNameHere» type= share to sc create «YourServiceNameHere» . After running the service create command with the type specified, change the output of the sc query command and shows it’s running in it’s own process and the service successfully starts and continues running.

I really hope this helps someone, it caused me much stress!

Windows service was started and then stopped

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I have a windows service and it was working fine, and today I tried to stop it and unlike the usual stop process, this one took a longer time. The next time I want to start the windows service, it raise an error that the service started and then stopped, it also said that service with no job stops automatically. When I checked the event log, there is no event about my service. My service worked well yesterday, in fact, it worked as usual just before I tried to stop it . but then I don’t know why the error appeared, I don’t think I did any changes to the database..

Any solutions ? or if someone can share his/her own problem similar to this

What my windows service do: read a log file, write to log file, then access database, then execute a stored procedure in 2 hours interval..

Edit: I even tried to restart my computer after the problem keep happening when i try to start the service, but it doesn’t solve the problem.. now I cant start my service. One way I found to solve this problem is by re-installing the service. However, I need a better solution because I don’t want to keep re-installing the service if this problem appeared.

C# Windows Service — the service on local computer started and then stopped?

I am trying to create my first Windows Service, but so sad. after I started the service manually from services.msc, the message ‘the service on local computer started and then stopped. some services stop automatically is they have no work to do’

I am sure there must be some mistake in my code.

Forgive me if i did silly mistakes. This is my very very first Windows Service.

PS. I have already ticked ‘Allow service to interact with desktop’

3 Answers 3

Check to make sure the account your service runs under can access those files (including write access for the .wav and .mp3 files).

Your code might also be causing an unhandled exception. I’m not sure, but that might be visible in the event log. You can also get your service to write out messages explicitly to the event log (like in the case of an exception); check out this link: http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx

You didn’t create a running thread for the OnStart method. Basically, the service manager calls OnStart to start the service, and that call needs to finish in about 15 seconds or so. Internally, you should create a thread with a loop that actually calls your code over time. Like so:

Your service doesn’t really follow the pattern; you’re not doing things continuously, and that should be more of a console program.

Effectively, it’s because your service stopped doing anything as soon as you finished the OnStart method. It’s like what happens when you finish Main in a console program — the application just exited.

The Windows Defender Service on Local Computer started and then stopped.

When attempting to start defender in services.msc I get this message: The Windows Defender Serviceservice on Local Computer started and then stopped. Some services stop automatically if they are not in use by services or programs.

This started after today’s update 8/7/2015.

I was able to start Windows Defender Network Inspection Service but it says startup type is Manual. That doesn’t seem right.

Thank you for being part of Windows 10 family.

Sorry to know that you are facing issues with Windows 10.

In order to help you better, please provide the information:

Have you installed any third party security software on the Computer?

If so, then i would suggest you to disable or uninstall the third party security software and check if the issues persist.

Disable Anti virus:

NOTE: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you shouldn’t disable your antivirus software. If you have to temporarily disable it to install other software, you should re-enable it as soon as you’re done. If you’re connected to the Internet or a network while your antivirus software is disabled, your computer is vulnerable to attacks.

Refer to the below methods and check if it helps.

Method 1: I suggest you to perform the system maintenance troubleshooter. It will resolve the common system problems.
1. Tap on Windows Key and click on search bar.
2. Type “Troubleshooting” without the quotes and click on Troubleshooting.
3. Then click on System and Security.
4. Click on System Maintenance.
5. Click on Next and follow the prompts to run the troubleshooter.

If the issue still persist, refer to the below method.

Method 2 : I suggest you to perform a System File Checker of the Computer and check if it helps.

1. Press Windows Key.

2. Then type “CMD ” without the quotes and right click on it.

3. Select Run as Administrator .

4. Then type” sfc /scannow ” without the quotes and hit on Enter Key .

If the issues still persist, refer to the below methods.

Reply with the information, so that we can help you better.
Hope it helps. Contact us if you need any further assistance, we will be glad to help.

Backups are working fine, but i can’t open the program to restore a file i need. Attempting to open the program results in Service suddenly stopped working.

I have read thru the linked article, and all of the forum posts about this issue on this site and followed everything i could find but it still happens.

The actual service will not start in services.msc, regardless if i set it to log in as domainadministrator, or a newly created administrator-level account, or even local service. All attempts end with «…the service started and then stopped…» the typical windows message

When the attempt is made, event viewer id 0 happens with the below text

My support case has been unanswered for several days (i realize it’s a free product, but we also have a valid license for 250 users of m365 backups thru veeam). The case id is 05327231

I have reset the registry keys to rebuild the database after having renamed the temporary folders where the database lives (deep in c:windowssystem32…)
i have rebooted several times
i have ran the latest product installation (which seemed to install ok until the very end when it errored out on starting the service)
i have opened the support case and my logs were updated on Friday last week

This is what i call a standard setup, one server on one domain — no proxies or anything weird. Backups run to an external usb hard drive and logs say backups are working fine

The text from the event viewer ID zero is:

Code: Select all

Service cannot be started. Veeam.Backup.Common.CConnectionFailedException: [This server] Failed to connect to Installer service. ---> Veeam.Backup.Common.CConnectionFailedException: [This server] Failed to connect to Installer service. ---> System.Exception: [This server] Failed to discover Installer service. ---> System.Exception: [This server] Failed to check whether remote Installer service is available. ---> System.ApplicationException: The RPC server is unavailable
RPC function call failed. Function name: [GetSvcVersion]. Target machine: [127.0.0.1].
   at VeeamProxyClient.RegenerateCLRException(exception* excBase)
   at VeeamProxyClient.CCliVeeamDeployer.PingService()
   at Veeam.Backup.ProxyProvider.CProxyRawDeployerService.TestConnection(String srvName, CCliVeeamDeployer veeamDeployer)
   --- End of inner exception stack trace ---
   at Veeam.Backup.ProxyProvider.CProxyRawDeployerService.Connect(String srvName, IPAddress[] ips, CCredentials creds, Int32 configPort, Boolean install)
   at Veeam.Backup.ProxyProvider.CPro...

Discus and support Service starts and then stops immediately. in Windows 10 BSOD Crashes and Debugging to solve the problem; Hi,

I have a program that needs a service running to work. The service won’t start automatically as it should and when I start it manually it starts…
Discussion in ‘Windows 10 BSOD Crashes and Debugging’ started by LeonTheron1, Mar 4, 2021.

  1. Service starts and then stops immediately.

    Hi,

    I have a program that needs a service running to work. The service won’t start automatically as it should and when I start it manually it starts and then stops immediately. Error message says some services stop when not being used.

    How do I overcome this. my program won’t run.

    It used to work fine before a system re-install. I did re-install the program.

    :)

  2. Printing stopped with November upgrade

    Hey Prestonpdx,

    I would suggest you check if the print spooler is running. Start/Stop print spooler service. Follow the steps below.

    • Press Windows key + R, type services.msc
      and press Enter.
    • From the list, locate Print Spooler service.
    • Double click on the service and select Stop.
    • Restart the computer, repeat step 1&2.
    • Double click on the service and check if the service is started.

    Get back to us with the updated status, we’ll be glad to assist you.

    Thank you.

  3. Windows Update — Service registration is missing or corrupt

    Hi Nitya,

    Upon analyzing the details and the troubleshooting steps you have done so far, we suggest that you
    manually reset your Windows Update Components
    by following these
    troubleshooting steps:

    • Run
      Command Prompt as Administrator
    • Stop
      BITS, Cryptographic, MSI Installer and Windows Update Services. To do this,
      type the following command:

      • Net stop wuauserv
      • Net stop cryptSvc
      • Net stop bits
      • Net stop msiserver
    • Rename
      SoftwareDistribution
      and
      Catroot2
      folder. To do this, type the following commands:

      • Ren C:WindowsSoftwareDistribution SoftwareDistribution.old
      • Ren C:WindowsSystem32catroot2 Catroot2.old
    • Restart
      BITS, Cryptographic, MSI Installer and Windows Update Services. To do this,
      type the following command:

      • Net start wuauserv
      • Net start cryptSvc
      • Net start bits
      • Net start msiserver
    • Restart
      your computer and try to
      install Windows Update.

    Update us on how it goes.

    Regards

  4. Service starts and then stops immediately.

    unable to start the Windows time service on Windows 10

    Hi Enriq,

    As you are facing issue with starting the Windows Time Service, do not worry we will help you with this issue.

    Do let us know the following to assist you better with this issue:

    • What exactly happens when you try to turn on the service?
    • What is the complete error message/ error code of this issue?
    • Have you made any changes to the operating system prior to this issue?

    Method 1: I suggest you to run a SFC scan and check if it helps.

    System File Checkeris a utility in Windows that allows users to scan for corruptions in Windows system files and restore corrupted files.

    Follow the below steps:

    • Right click on the Start button, click on
      Command Prompt (Admin).
    • Type “sfc /scannow” without the quotes and hit
      Enter.
    • After the scan, restart the computer and check for the issue.

    Note: If you are not able to repair some files after performing SFC scan, I suggest you to refer to the point 3 “Windows Resource Protection found corrupt files but was unable to
    fix some of them. Details are included in the CBS.Log %WinDir%LogsCBSCBS.log”. Under the section “Run the System File Checker tool (SFC.exe)” to repair the corrupted files after performing SFC scan.

    Refer: Use the System File Checker tool to repair missing or corrupted system files

    Method 2: I suggest you to Restart Windows Time Service and check if it helps.

    Windows Time Service maintains date and time synchronization on all clients and servers in the network. If this service is stopped date and time synchronization will be unavailable. If this service is disabled,
    any services that explicitly depends on it will fail to start.

    Step 1: Stop the service:

    • Press Windows Key + R on the keyboard and type
      services.msc, Services window gets opened.
    • Search for Windows Time service and stop.
    • To do so, right click on each service select Stop
    • Restart the device.

    Step 2: Start the service and set it to automatic:

    • Press Windows Key + R on the keyboard and type
      services.msc
      , Services window gets opened.
    • Search for Windows Time service, right click on it and click on
      Properties.
    • Start the service, set
      Startup type to Automatic.

    Hope it helps. Kindly update the status of accessing the Windows Time Service for further assistance.

    Thank you.

Thema:

Service starts and then stops immediately.

  1. Service starts and then stops immediately. — Similar Threads — Service starts stops

  2. browserhost.exe is run and then stop immediately

    in AntiVirus, Firewalls and System Security

    browserhost.exe is run and then stop immediately: my browserhost.exe on chrome won’t work correctly like usuall they stop and then start again stop again the process is looping making the CPU usage high how to fix it plssss…
  3. The Diagnostic Policy Service starts and then stops, cannot be started.

    in Windows 10 Network and Sharing

    The Diagnostic Policy Service starts and then stops, cannot be started.: The Diagnostic Policy Service DPS is set to automatic, but it won’t run. It starts and immediately stops. When I try to start the service manually, I get the message that «The Diagnostic Policy Service service on Local Computer started and then stopped. The windows network…
  4. The Diagnostic Policy Service starts then stops

    in Windows 10 Drivers and Hardware

    The Diagnostic Policy Service starts then stops: When I try and troubleshoot my network I get greeted with the message “Diagnostics Policy Service is not running” and when I press try these repairs as administrator it doesn’t do anything. Then when I tried manually turning it on it told me “The Diagnostic Policy Service on…
  5. Cannot stop and start the Dhcp service.

    in Windows 10 Customization

    Cannot stop and start the Dhcp service.: Hello, for something I’m working on I need to be able to stop and start the DHCP service. However, I am unable to do so because when I tried to attempt to stop the service I get «Access is denied» and «System error 5 has occurred». I do not believe the problem is because…
  6. Stop music cd from starting to play immediately on loading

    in Windows 10 Drivers and Hardware

    Stop music cd from starting to play immediately on loading: A simple question, I guess.

    When I insert a music CD into my built-in CD-ROM the bl…..dy music starts playing right away. It’s getting on my nerves because what I actually want to see is an Explorer type of page listing the individual files. I know there must be a setting…

  7. Stopped Service

    in Windows 10 Customization

    Stopped Service: Good day,

    I just need to know what the following service is:

    Description: mdmmcdalaska

    File Path: «C:windowsSysWOW64mdmmcdalaska.exe»

    Regards,

    https://answers.microsoft.com/en-us/windows/forum/all/stopped-service/b4c47d0a-c47f-41a3-aaca-d559be674419

  8. Stopping services

    in Windows 10 BSOD Crashes and Debugging

    Stopping services: Hello,

    Dear Sir/Madam i have Windows 10 pro and want to give me a list of the services within the Windows 10 that can be switched off in order to have a better performance to your computer. I don’t use all services and eat resources in vain in Windows 10 pro
    expect answer!…

  9. Win 10: Services stuck on starting/stopping, programs not starting

    in Windows 10 Support

    Win 10: Services stuck on starting/stopping, programs not starting: Hi all! I’m facing this issue that is really annoying since I can’t find out what is the cause.
    It started about one week ago, I notices some programs were not starting at windows start (ex: Coretemp, Malwarebytes).
    Moreover, the pc always got stuck on the reboot or…
  10. Start, Stop, and Disable Services in Windows 10

    in Windows 10 Tutorials

    Start, Stop, and Disable Services in Windows 10: How to: Start, Stop, and Disable Services in Windows 10

    How to Start, Stop, Restart, Enable, and Disable Services in Windows 10

    [img]
    Information A service is an application type that runs in the system background without a user interface and is similar to a UNIX…

Users found this page by searching for:

  1. service starts but stops


Windows 10 Forums

Понравилась статья? Поделить с друзьями:
  • Windows service pack 3 download 64 bit
  • Windows service pack 1 ошибка при запуске
  • Windows service pack 1 windows 7 ultimate x64 торрент
  • Windows service for secondary logon windows 10
  • Windows service background intelligent transfer service