Question about making a batch file

Joined
Aug 14, 2015
Messages
2,444
Location
CA, USA
I decided to follow the instructions here (https://www.technewstoday.com/how-to-clear-printer-queue/) about making a batch file that will stop and then restart the Windows print spooler, to clear out print jobs when an error in printing occurs. Not wanting to screw this up, I looked at a youtube video on making a batch file, which if I'm not mistaken, says the first characters of a batch file should be "@ECHO." The instructions on the page I just linked to didn't say anything about that. Do I need those characters at the top of my batch file? Or was that just for the type of file that he is making in the video? See about 40 seconds into the video for what I'm taking about.

 
Oh actually I'd prefer seeing the command line consule. That is kind of like seeing an icon in the system tray--it tells me the program is up and running. So I'll take that line out.

Thanks.

The @echo just mutes displaying each command line as the batch file executes. Not necessary unless you don't want to see each command displayed on the console.
 
The @echo just mutes displaying each command line as the batch file executes. Not necessary unless you don't want to see each command displayed on the console.

I just learned something new today, thank you sir.

1659554756486.jpg
 
Oh actually I'd prefer seeing the command line consule. That is kind of like seeing an icon in the system tray--it tells me the program is up and running. So I'll take that line out.

Thanks.
If I'm not mistaken, the command line window will pop up, blow through the commands, and close the window and you won't be able to read anything anyway. Of course, you can add "pause" to the end of your batch file. That will output "Press any key to continue..." before it closes the window.
 
Just thought I'd mention that most, if not all, dos/command line "commands" will return a description/list of options for that command if you follow it with a space /?

Just open a command prompt box and enter as below.

for example:
echo /?
ping /?
copy /?
 
That's how I've always experienced those batch files. Which is fine by me... like I said, it lets me know the utility worked.

If I'm not mistaken, the command line window will pop up, blow through the commands, and close the window and you won't be able to read anything anyway. Of course, you can add "pause" to the end of your batch file. That will output "Press any key to continue..." before it closes the window.
 
Oh actually I'd prefer seeing the command line consule. That is kind of like seeing an icon in the system tray--it tells me the program is up and running. So I'll take that line out.

Thanks.
Yeah, @echo on or off determines whether you see the commands being executed or just the result. As @Hall noted, you can also call a pause at the end of the file if you don't want it to immediate close after it has been run.

Don't think you need the video, this particular batch file is VERY straight forward, the instructions in the link should be enough.

Just open Notepad, and put in:

@echo off
net stop spooler
del %systemroot%\System32\spool\printers* /Q /F /S
net start spooler
pause

Then do a Save As, choose "all files" under type and then name it something like SpoolerPurgeRestart.bat

When you go to run it, right-click, run as administrator.
 
  • Like
Reactions: JC1
You can send the output from the batch file to another file. I used to do that for backup/copying files to/from server. Push date date to file, push output from copy commands. Then I had history of when I ran the file.
 
Back
Top