Jump to content

script or batch file to stop printer spool service, delete spool files, restart servi


Recommended Posts

Posted

Hi,

On of my schools is having major issues with print jobs getting stuck in the spool folder, see this post for info: http://www.edugeek.net/forums/hardware/98241-printers-causing-me-no-end-problems.html for the moment I need to find a way to let the staff fix the issue as it happens and think some kind of script would be best, although open to suggestions.

 

I need to create a script that allows a user to stop the spools service running on the server, delete all files in the spool folder and then restart the spool service.

 

I have no idea how I would create this, so thanks for any help.

Posted

You need to get a copy of the psexec.exe program (can't remember where from but its free - google it)

 

batch file rough outline:

 

[i]pathtopsexec[/i]\psexec.exe [i]servername[/i] net stop "print spooler"
[i]pathtopsexec[/i]\psexec.exe [i]servername[/i] del c:\windows\system32\spools\printers\*.*"
[i]pathtopsexec[/i]\psexec.exe [i]servername[/i] net start "print spooler"

 

Something like that might work - you may need to allow the users some more permissions though as I doubt their accounts will be able to do that on a server

  • Thanks 1
Posted
You need to get a copy of the psexec.exe program (can't remember where from but its free - google it)

 

batch file rough outline:

 

[i]pathtopsexec[/i]\psexec.exe [i]servername[/i] net stop "print spooler"
[i]pathtopsexec[/i]\psexec.exe [i]servername[/i] del c:\windows\system32\spools\printers\*.*"
[i]pathtopsexec[/i]\psexec.exe [i]servername[/i] net start "print spooler"

 

Something like that might work - you may need to allow the users some more permissions though as I doubt their accounts will be able to do that on a server

 

To use psexec they will need to be local admins on the server.

  • Thanks 1
Posted
To use psexec they will need to be local admins on the server.

 

Yeah its not an ideal fixit. It would obviously be better to fix the actual problem rather that patch it up like this. Think I will re-read the linked thread and try and come up with something else

  • Thanks 1
Posted
It will be a driver I am sure. Have you installed another printer recently and this has just started.

 

Recently changed the server and all printers from HP to Dell, but still have the same issue.

Posted

I am getting PsExec could not start Del on server using the script.

 

Any ideas.

 

pathtopsexec

\psexec.exe

servername

net stop "print spooler"

pathtopsexec\psexec.exe servername del c:\windows\system32\spools\printers\*.*" pathtopsexec

\psexec.exe

servername

net start "print spooler"

  • 5 years later...
Posted

I know this is a fairly old thread but I'm having the same problem and I've nearly got a workaroud but not quite there.

The problem we have is that when a user on a Windows 10 laptop prints it sometimes jams up the spooler. I've tried to re-create the problem but I can't. Konica printer on 2012R2 server.

The way to fix it is to go to the server, login as admin stop print service, delete temp files and start print service again.. I'm not abou tot let the users loose on that.

 

Picking up the threads above I've nearly succeeded with this script - this does launch a cmd file in the windows\system32 folder of my server at my desktop.

So far so good, but I can't delete the printers folder contents

>>> The problem I think we are all having is this one...

 

 

If I go to the console of the serve and log on locally, make a batch file in c:\windows\system32 I can run it from psexec and I can run it locally.

IF the batch file tries to get to the spool folder okay

Getting to printers folder with batch file is prevented by something - but I don't know what!!

I can browse to the spool\printers folder and delete the files no problem.

 

pausef:\fixprintjam\psservice.exe \\svr-ois-dc01 -u ois\?????????? -p ?????????? stop "print spooler" pausef:\fixprintjam\psexec.exe \\svr-ois-dc01 -u ois\?????????? -p ?????????? cmdpausef:\fixprintjam\psservice.exe \\svr-ois-dc01 -u ois\?????????? -p ?????????? start "print spooler"pause

Posted
i bet its printing from edge/pdf viewer/modern apps they do not like copiers/printers that need codes the prompt never appears then the screw up the print queue. Ive found 2 workrounds 1 i have a script that deletes all print jobs every 30 mins bit of a brute force approach or remove codes from the printer
Posted
The driver is crashing change the driver if you are using a pcl5 try a pcl6 you get the idea also make sure you have latest drivers Richard
Posted

sorry - I cn see line breaks didn't appear above.

This one is odd, I ccan't repeat it -but I think I've fixed it -

I gave the admin full control of the spool/printers folder and then made a batch file in c:windows\system32 that changed directory to spool/printers and just deletes what's there.

the psexec line now runs that batch file

  • Thanks 1
Posted

Hi Ricki - your info from spiceworks was exactly what i was looking for, the code I've put in above uses the pstools download from sysinternals - that lets a user run a simple batch file on a specified PC against the print spooler on the server does that set of tasks..

I agree about drivers - there's nothing in the event logs to give me any clues, but hopefully this is a bit better for them and for me :)

Posted
Something I have seen is when the printer is installed if it uses the WSD ports is creates random issues, change it to a standard TCP/IP one where applicable and you will find some issues might go away.
Posted
Something I have seen is when the printer is installed if it uses the WSD ports is creates random issues, change it to a standard TCP/IP one where applicable and you will find some issues might go away.

 

Hi Matthew, I had spotted that it was trying to do that, I’m fairly sure it’s all TCP/IP and or server share. I wish I could actually recreate the problem!!

Posted

Another me too. I write a poweshell script that runs every hour originally I think. I’ve fine tuned it now so it looks for ‘stuck’ print jobs and if it finds any stops the spoiler, deletes Job and restarts. So I could run it more frequently now.

 

And this is a custom driver deployed via Ricoh print driver creator software. I had to use that to get the code prompt to work on clients.

 

I’m hoping when they upgrade the copier we won’t have the problem. It defo comes from using the edge browser or the win 10 photos app.

Posted
Trust me it's a driver are there multiple printers on the print server. If so either disable one type of printer at a time or change one driver at a time. My guess is a photocopier especially if you use encrypt and print

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...