Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script for restarting Print Spooler by user on DC 1

Status
Not open for further replies.

mirceapop14

Programmer
Apr 1, 2004
69
RO
How can i write a script witch will be execute by an user , as a simple user, when Printer spooler fails on Windows Server 2000 Domain Controller ? Can this be done in another way manually not by script ?
Thanks.
 
go to the command prompt and type net start spooler and it'll try to start the service.
 
If the service is already running but unresponsive you will first need to do a net stop spooler, then a net start spooler.



I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Manually solution is good, but i need to do that from an user account wich have no rights on server and no knowledge for doing that. The use need just to double click on an icon for restarting printer spooler on server.
Thanks again !
 
If it is crashing out you can get Windows to restart it itself. Look at the recovery tab under services.

Not sure how it handles unresponsiveness though.
 
maybe you could make a batch file and then in properties run as administrator.
 
Easiest solution would be to set up IIS on that server. Set the anonymous credentials for the site to be the administrator ID and have a script that runs in ASP that stops and restarts the service.

Here is some sample code.
Code:
'==========================================================================
'
' NAME: StopStartSpooler.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 10/18/2004
'
' COMMENT: <comment>
'
'==========================================================================

On Error Resume Next

'start with getting the local computer name
strComputer = "."

'now stop the services
Set objWMI = getobject("winmgmts://" & strComputer)
StopService ("Spooler")
WScript.Sleep 3000
StartService ("Spooler")

'sub to stop the services
Sub StopService (ServiceName)
         queryString = "select state from win32_service " _
               & "where displayname='"& ServiceName & "'"
         set results = objWMI.execquery(queryString)
         for each service in results
            if service.state = "Running" then
             service.stopService
            end if
          next
End Sub

'sub to start the services
Sub StartService (ServiceName)
         queryString = "select state from win32_service " _
               & "where displayname='"& ServiceName & "'"
         set results = objWMI.execquery(queryString)
         for each service in results
            if service.state <> "Running" then
             service.startService
            end if
          next
End Sub


I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Please explain me what means"Set the anonymous credentials for the site to be the administrator ID".
Here is my situation:
I have a default site wich is designated to a special program wich works with IIS. So you say to create other site and any anonymus user for that site could restart the service ?
Thanks again.
 
From within IIS right click Web Sites and choose New/Site.

Right click the new site, choose properties.

Either give it a different IP than your default site or give it a host header.

Click the Directory Security Tab. Click Edit in the section for Anonymous Access. Replace the default IUSER_ id with your admin ID and password.

This will allow any code executed on this site to use the admin credentials.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top