Results 1 to 3 of 3

Thread: Check if the Print Spooler Service is running?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2015
    Posts
    1

    Check if the Print Spooler Service is running?

    Hi all

    I've managed to find this in VB.net, but I can't seem to find a native method to check whether the Print Spooler service is running (and, optionally, start/restart it if not)

    Is there a library or snippet anyone can point me towards?

    Thanks

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Check if the Print Spooler Service is running?

    See the Shell object's IsServiceRunning, ServiceStart and ServiceStop methods. Here's an example:

    Code:
    Option Explicit 'In a standard Module
    
    Private Sub Main()
        With CreateObject("Shell.Application")  'Or New Shell if Microsoft Shell Controls And Automation is referenced
            If .IsServiceRunning("Spooler") Then
                .ServiceStop "Spooler", False
            Else
                .ServiceStart "Spooler", False
            End If
        End With
    End Sub
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Check if the Print Spooler Service is running?

    Most services can only be started and stopped by an elevated process.

    This entire topic is an administration issue and not something an application should be playing with anyway. If somebody is shutting down the spooler you have bigger fish to fry. Just restarting it isn't a viable solution.

Posting Permissions

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



Click Here to Expand Forum to Full Width