Wally J
2023-12-23 23:03:35 UTC
I do it manually but is there a command that can be put in a file attached
to a shortcut so that I can start and stop the print spooler on demand?
Merry Christmas!to a shortcut so that I can start and stop the print spooler on demand?
How does this look for solving almost every problem stated in this thread?
<Loading Image...>
The only issue it doesn't solve is changing the icon color based on status.
It's not worth spending time writing a tutorial to help only one person,
but it's probably worth it to help everyone who ever uses a printer.
We did sort of the same thing (only different) with the nettoggle command
that turns on and off the gateway to connect/disconnect from the network.
Based on that & the information in this thread, I hacked this out; but I
always easily readily admit I am not a programmer by any means whatsoever.
So I've taken the liberty of including the batch experts on the question.
I started with the nettoggle.bat file originally provided mostly by
Zaidy036 20210207 on alt.comp.os.windows-10 which I modified by adding
the information provided by Andy Burns & VanguardLH & Zaidy036 again.
Testing...
Win+R > services.msc
Set the "Print Spooler" "Startup Type" to "Manual".
Manually "Stop" the "Print Spooler" for a known starting point.
Win+R > spooler [Enter]
Tada. Windows cannot find spooler. <== critically important step!
Win+R > cmd [Control][Shift][Enter]
C:\> spooler [Enter] <== the reason for this becomes evident later
'spooler' is not recognized as an internal or external command,
operable program or batch file.
C:\> sc query | findstr /i spooler
C:\> if not errorlevel 1 echo "Spooler is running. Kill it?"
C:\> net stop spooler
The Print Spooler service was stopped successfully.
C:\> sc query | findstr /i spooler
C:\> if errorlevel 1 echo "Spooler is not running. Start it?"
C:\> net start spooler
The Print Spooler service was started successfully.
C:\> vim C:\data\sys\batch\spooler.bat
===< see below for spooler.bat version 0.1 >===
@echo off
REM 20231223 spooler.bat v0.1 starts & stops the Windows print spooler
REM using admin-only commands suggested by Andy Burns & VanguardLH
REM in Usenet thread Message-ID: <um4j5t$1vls9$***@news.samoylyk.net>
REM A taskbar bat shortcut will be more complex as it will likely require
REM creating a new scheduled task as suggested by Zaidy036 in that thread
REM This runs from either a shortcut or from the Run command box.
REM
call sc query | findstr /i spooler
if %ERRORLEVEL% == 0 goto :Stop?
:Start?
set /p user_input=Spooler is not running. Start it?"
if %user_input%==y net start spooler
goto :Icon
:Stop?
set /p user_input=Spooler is running. Stop it?"
if %user_input%==y net stop spooler
:Icon
echo "Change shortcut icon color (red/green) depending on outcome"
exit 0
===< see above for spooler.bat version 0.1 >===
What needs to be added is to make this a taskbar shortcut, where the
suggestion by david to change the color is well beyond my humble skills.
Even making it a taskbar shortcut is much harder than it at first
might appear to someone who has never made a shortcut to a non-desktop
batch file which you'd want to also be called from the Win+R command.
For the print spooler shortcut's icon, you'll likely want what we did
with nettoggle by getting it in two colors (red=off & green=on).
This starts a typical quest for the taskbar shortcut togging icons.
<https://www.google.com/search?q=print+spooler+icon>
But I like to use the icon method I devised for Android outlined here:
<https://groups.google.com/g/comp.mobile.android/search?q=tutorial%20one-tap>
Which starts with an images.google.com search for an appropriate icon.
<https://www.google.com/search?q=icon+print+spooler&tbm=isch>
Which can net you an icon file which you can then colorize as needed.
<https://thenounproject.com/browse/icons/term/print-spooler/>
Or simply use anything that you like that you have displayed on the screen.
a. Press "print screen" on any listing of any number of icons
b. Paste with Control+V into Irfanview & crop using Control+Shift+Y
c. Save as a 48x48px ico file with transparent background if desired
c. Save as C:\data\sys\icon\spooler.ico
It's hard enough to pin a shortcut to a batch file to the taskbar,
and then you still have to run the batch file as administrator, where
you can add the suggestion from Andrew but it's a big security hole:
runas.exe /user:administrator /savecred "%mycommand%"
Instead, I'd use Zaidy036's suggestion for the easiest way to put a
shortcut to an admin command running inside a batch file on the Windows
taskbar is to set up a scheduled task in the Windows Task Scheduler.
To make that scheduled task and to run as administrator:
Win+R > taskschd.msc > Task Scheduler Library > Create Task...
Name = task spooler
Description = start/stop print spooler
Security options = [x]Run with highest privileges
Actions = New > Start a program
Program/script = %comspec%
Add arguments = /c start "" c:\data\sys\batch\spooler.bat
Test that newly created task by rightclicking on it as listed in the
"Task Scheduler Library" listing & selecting "Run" from the context menu.
The hardest part, sometimes, is making a shortcut to a batch file that
Windows will allow the option to pin to the taskbar. The easiest way
to circumvent all those difficulties (try it if you don't believe me),
is to completely ignore the batch file you just made.
Instead, create a shortcut to the scheduled task & not to the batch file!
completely by just making a shortcut that ignores the batch file except to
put it in the comments so that you can find it years from now if needed.
Using Zaidy036's suggestion, the spooler.bat.lnk shorcut TARGET is:
TARGET=C:\Windows\System32\schtasks.exe /run /TN "task spooler"
COMMENT=C:\data\sys\batch\spooler.bat
Advanced = [x]Run as administrator
Which you can create from scratch using the rightclick context menu:
a. Open Windows file explorer to C:\data\sys\link\
b. Rightclick > New > Shortcut
c. In "Type the location of the item:", paste this target line:
C:\Windows\System32\schtasks.exe /run /TN "task spooler"
d. Next
e. In "Type a name for this shortcut", call it "spooler"
f. Finish
g. Rightclick on the resulting "spooler.lnk" file
h. Set "Comments" to "%comspec% /c start "" c:\data\sys\batch\spooler.bat"
i. Click the "Change icon" button
j. In "Look for icons in this file", press "Browse" to go to where
you created the icon, e.g., "C:\data\sys\icon\spooler.ico"
k. Press "OK"
l. Rightclick on that shortcut & select "Pin to Taskbar"
Notice this avoids all the problems inherent in Windows' dislike of taskbar
shortcuts to admin batch files since the shortcut points to the scheduled
task (so only the admin scheduled task is what points to the batch file).
Also, by posting this to archived newsgroups, it also solves the original
problem of searching for the problem set to find an exact solution for it.
<http://alt.comp.os.windows-10.narkive.com>
<http://groups.google.com/g/alt.msdos.batch>
<http://groups.google.com/g/alt.comp.microsoft.windows>
As always, if you know more than I do, please add on-topic value,
especially if you can figure out how to change the icon color on the fly.
--
Usenet is a team of intelligent experienced people who help each other out.
The result is saved into the combined tribal knowledge of the newsgroup.
Which is available to the entire world to benefit from now & in the future.
Usenet is a team of intelligent experienced people who help each other out.
The result is saved into the combined tribal knowledge of the newsgroup.
Which is available to the entire world to benefit from now & in the future.