Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Making a windows service

  1. Registered TeamPlayer DJ Ms. White's Avatar
    Join Date
    11-13-07
    Location
    Plano, TX and Ruston, LA
    Posts
    32,364
    Post Thanks / Like
    Blog Entries
    43
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    Steam ID: DJMrWhite
    #1

    Making a windows service

    There's a long running problem with the software used to control the music my station plays over the air. Namely, two services either stop running or hang. This causes the computer to lose access to the internet; no other computer on the network is affected. Restarting the program fixes the issue.

    My question is would it be possible to write code to make a constantly running windows service that would check the states of those faulty services and restart them when needed? Or, would it be better to just write a little program that would sit in the systray? What language would I write it in?

    The non-duck tape solution would be to install the music program correctly (whoever did that borked it), and to first install a 64 bit OS on the computer (it's a 64bit system, but the same person who borked the install of the program put a 32 bit system on it...he's a comp sci major..soooo -_-). Unfortunately, this would require us to pay for install time that would cost a few grand. So...it ain't gonna happen soon.
    enf-Jesus its been like 12 minutes and you're already worried about stats?! :-P
    Bigdog-
    Sweet home Alabama you are an idiot.

  2. Registered TeamPlayer
    Join Date
    09-15-07
    Posts
    1,559
    Post Thanks / Like
    Stat Links

    Making a windows service Making a windows service
    #2

    Re: Making a windows service

    Vbscript should be able to handle it. Probably better ways to do it but what works, works. Put a timer in it to check every x seconds and loop.

  3. Registered TeamPlayer DJ Ms. White's Avatar
    Join Date
    11-13-07
    Location
    Plano, TX and Ruston, LA
    Posts
    32,364
    Post Thanks / Like
    Blog Entries
    43
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    Steam ID: DJMrWhite
    #3

    Re: Making a windows service

    Would VB let me have a GUI to let the lay person do a manual reset so to speak?
    enf-Jesus its been like 12 minutes and you're already worried about stats?! :-P
    Bigdog-
    Sweet home Alabama you are an idiot.

  4. Registered TeamPlayer Warprosper's Avatar
    Join Date
    09-01-08
    Posts
    5,775
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    PSN ID: Warprosper Steam ID: Nukewarprosper Warprosper's Originid: Warprosper
    #4

    Re: Making a windows service

    I can build you one in powershell with a gui if you want. Give me the name of the services and i'll work something up. Should only take a few minutes..

    Also.. What is the query interval you want to check to see if they're running?

  5. Registered TeamPlayer DJ Ms. White's Avatar
    Join Date
    11-13-07
    Location
    Plano, TX and Ruston, LA
    Posts
    32,364
    Post Thanks / Like
    Blog Entries
    43
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    Steam ID: DJMrWhite
    #5

    Re: Making a windows service

    I'll find out the services' names.

    As for query interval, I'm not sure. The services generally only stop once a day. Maybe once every hour then?
    enf-Jesus its been like 12 minutes and you're already worried about stats?! :-P
    Bigdog-
    Sweet home Alabama you are an idiot.

  6. Registered TeamPlayer Warprosper's Avatar
    Join Date
    09-01-08
    Posts
    5,775
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    PSN ID: Warprosper Steam ID: Nukewarprosper Warprosper's Originid: Warprosper
    #6

    Re: Making a windows service

    Here's the basis for the script ... It's powershell so you will need that installed if it's not.

    Interval is set to 5 seconds but you can change to whatever..


    I can make you an established GUI that's easy to use if you provide me with the service names





    While ($True)
    {
    #Service 1
    $ServiceName1 = Get-Service | Where-Object {$_.Name -eq "VDS"}

    if ($ServiceName1.Status -eq "Stopped")
    {
    Start-Service -Name "VDS"
    }

    Get-Service | Where-Object {$_.Name -eq "VDS"}

    #Service 2
    $ServiceName2 = Get-Service | Where-Object {$_.Name -eq "VDS"}

    if ($ServiceName2.Status -eq "Stopped")
    {
    Start-Service -Name "VDS"
    }

    Get-Service | Where-Object {$_.Name -eq "VDS"}

    Sleep -seconds (5)


    }
    Last edited by Warprosper; 02-07-13 at 08:14 AM.

  7. Administrator Kanati's Avatar
    Join Date
    05-15-08
    Location
    Pekin, Illinois, United States
    Posts
    17,724
    Post Thanks / Like
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service
    #7

    Re: Making a windows service

    That will work if the service enters stopped status. If it just hangs it's still going to just sit there. But that's a good start.

    Krakkens and shit. stop tempting them.
    -- Bigdog

  8. Registered TeamPlayer Warprosper's Avatar
    Join Date
    09-01-08
    Posts
    5,775
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    PSN ID: Warprosper Steam ID: Nukewarprosper Warprosper's Originid: Warprosper
    #8

    Re: Making a windows service

    Quote Originally Posted by Kanati8869 View Post
    That will work if the service enters stopped status. If it just hangs it's still going to just sit there. But that's a good start.
    There's no way to detect if a service is hanging or frozen.

  9. Registered TeamPlayer Phyrelight's Avatar
    Join Date
    07-18-07
    Location
    Arizona
    Posts
    3,620
    Post Thanks / Like
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    Steam ID: Phyrelight Phyrelight's Originid: Phyrelightaz
    #9

    Re: Making a windows service

    You could combine that with tellin it to automatically restart every XX hours :P Say 18 hours if it typically makes it a day before hanging? The dedicated kiosks I set up I have scripts i run that restart the computers at specified times to make sure they get updates and that no services are hanging. Saves me a service call.

  10. Registered TeamPlayer Warprosper's Avatar
    Join Date
    09-01-08
    Posts
    5,775
    Post Thanks / Like
    Blog Entries
    1
    Stat Links

    Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service Making a windows service
    Gamer IDs

    PSN ID: Warprosper Steam ID: Nukewarprosper Warprosper's Originid: Warprosper
    #10

    Re: Making a windows service

    Here's the GUI script ... 2 timers... One for querying the service to give you time to manually restart it the other is to have the script start it....Final function is for the restart button.. Green/Red icon indicators let you know status... and you can't see this here but it runs in the systray with balloon notifications instead of running in the taskbar..





    function OnApplicationLoad {
    return $true
    }




    function OnApplicationExit {
    $script:ExitCode = 0
    }


    $Form_Load={

    }


    #ServiceQueryTimer
    $Timerq = New-Object System.Windows.Forms.Timer
    $Timerq.Interval = 5000 # (5 Seconds)
    $Timerq.add_Tick({QueryServices})
    $Timerq.start()


    #ServiceStartTimer
    $Timer = New-Object System.Windows.Forms.Timer
    $Timer.Interval = 200000 # (2 Minutes)
    $Timer.add_Tick({ServicesStart})
    $Timer.start()


    function ServicesStart
    {

    #Service 1
    $ServiceName1 = Get-Service | Where-Object {$_.Name -eq "VDS"}

    if ($ServiceName1.Status -eq "Stopped")
    {
    $Color.BackColor = 'Red'
    Start-Service -Name "VDS"
    }
    else {$Color.BackColor = 'Green'}


    #Service 2

    $ServiceName2 = Get-Service | Where-Object {$_.Name -eq "PLA"}

    if ($ServiceName2.Status -eq "Stopped")
    {
    $Button1.BackColor = 'Red'
    Start-Service -Name "PLA"
    }
    else {$Button1.BackColor = 'Green'}




    }
    function QueryServices
    {

    $ServiceName1 = Get-Service | Where-Object {$_.Name -eq "VDS"}

    if ($ServiceName1.Status -eq "Stopped")
    {
    $Color.BackColor = 'Red'
    }
    else {$Color.BackColor = 'Green'}

    $ServiceName2 = Get-Service | Where-Object {$_.Name -eq "PLA"}

    if ($ServiceName2.Status -eq "Stopped")
    {
    $Button1.BackColor = 'Red'
    }
    else {$Button1.BackColor = 'Green'}

    }
    $StartServices_Click={
    #TODO: Place custom script here
    Start-Service -Name "VDS"
    Start-Service -Name "PLA"


    ServicesStart
    }
    Attached Images Attached Images Making a windows service-pic-png 
    Last edited by Warprosper; 02-08-13 at 12:32 PM.
    Likes Alundil, Phyrelight liked this post

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Title