|
-
Aug 7th, 2015, 05:17 AM
#1
Thread Starter
New Member
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
-
Aug 7th, 2015, 08:29 AM
#2
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)
-
Aug 7th, 2015, 09:49 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|