Running a program as a service

This is a discussion on Running a program as a service within the Windows Programming forums, part of the Platform Specific Boards category; How can I run my (Im using C) program as a service so it runs in the background? Is there ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    3

    Running a program as a service

    How can I run my (Im using C) program as a service so it runs in the background? Is there code to do it?

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    If you compile your program as a windows program and there is no output, it will run in the background and you will not notice it is running. I'm not sure if that is what your asking about though.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Do you mean how to make it not appear in the tasklist even?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    just make it so your do not ShowWindow() so there's not window thats popped up or just find another way to not create the actaul window itself...

  5. #5
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Look this up on msdn for more info but heres this copied from it:

    BOOL CreateProcess(
    LPCTSTR lpApplicationName,
    // pointer to name of executable module
    LPTSTR lpCommandLine, // pointer to command line string
    LPSECURITY_ATTRIBUTES lpProcessAttributes, // process security attributes
    LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes
    BOOL bInheritHandles, // handle inheritance flag
    DWORD dwCreationFlags, // creation flags
    LPVOID lpEnvironment, // pointer to new environment block
    LPCTSTR lpCurrentDirectory, // pointer to current directory name
    LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
    LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION
    );

  6. #6
    Registered User
    Join Date
    Nov 2002
    Posts
    3

    ...

    My program I want to run as a windows SERVICE, it would appear in XP task manager, but it runs in the background like services do. And most code you guys are spewing (heh) I don't like/understand cause I never program actual win32 exe's, my programs are command line.

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Looks like you're SCREWED then! j/k, I really have no clue.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    If you have never programmed for Win32 then I would recomend making a basic windows app and then try to make an app that runs in the background. There are several ways to do that just search around this board, there was a very in length discussion on it a while ago (like when i first signed up here over 2 years ago, but the thread is still around)

  9. #9
    Registered User
    Join Date
    Oct 2002
    Posts
    72
    I'm looking for the exact same info - command line windows program that needs to run as a service (start when the computer boots as opposed to when someone logs in & preferably doesn't show up in the task list)...

    I'm still searching for info, but if anyone knows an answer, feel free to post it.

  10. #10
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    You need to add a key pointing to your app in the registry, the key is in:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Curr entVersion\RunServices

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Running program in unix
    By Cpro in forum Linux Programming
    Replies: 2
    Last Post: 02-10-2008, 08:28 PM
  2. Running my program in the background
    By shoobsie in forum Windows Programming
    Replies: 4
    Last Post: 10-09-2005, 02:38 AM
  3. Replies: 3
    Last Post: 09-05-2005, 08:57 AM
  4. Why is my program running away?
    By badkitty in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2001, 04:27 PM
  5. Running program
    By muffin in forum C Programming
    Replies: 5
    Last Post: 08-30-2001, 10:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21