How to create a print batch file




















In this article, you'll learn how to write a simple batch file. You'll learn the basics of what batch files can do and how to write them yourself. I'll also provide you with further resources for learning to write batch BAT files.

Let's say that you frequently have network issues; you constantly find yourself on the command prompt, typing in ipconfig, and pinging Google to troubleshoot network problems. After a while, you realize that it would be a bit more efficient if you just wrote a simple BAT file, stuck it on your USB stick, and used it on the machines you troubleshoot.

A batch file simplifies repeatable computer tasks using the Windows command prompt. Below is an example of a batch file responsible for displaying some text in your command prompt. Double-click this New Text Document to open your default text editor. Copy and paste the following code into your text entry. The above script echoes back the text "Welcome to batch scripting! End your file name with the added BAT extension, for example welcome.

This will finalize the batch process. Now, double-click on your newly created batch file to activate it. Don't assume that's all batch scripting can do. Batch scripts parameters are tweaked versions of command prompt codes, so you are only limited to what your command prompt can do.

For those unfamiliar with the program, the command prompt is capable of quite a lot. Batch files use the same language as the command prompt. All you're doing is telling the command prompt what you want to input using a file, rather than typing it out in the command prompt. This saves you time and effort.

It also allows you to put in some logic, like simple loops, conditional statements, etc. This parameter is useful for viewing your working code. If any issues arise from the batch file, you will be able to view the issues associated with your script using the echo function.

Batch files use the same language as the command prompt. All you're doing is telling the command prompt what you want to input using a file, rather than typing it out in the command prompt. This saves you time and effort. It also allows you to put in some logic, like simple loops, conditional statements, etc. This parameter is useful for viewing your working code. If any issues arise from the batch file, you will be able to view the issues associated with your script using the echo function.

Adding a following off to this parameter will allow you to quickly close your script after it has finished. The library for batch variables is huge, to say the least. Luckily there is a Wikibook entry that holds the extensive library of batch script parameters and variables at your disposal. We'll create three examples of batch scripts which can simplify your daily online and offline activities.

Let's create an immediately useful batch script. What if you wanted to open all your favorite news websites the moment you wake up? Since batch scripts use command prompt parameters, we can create a script that opens every news media outlet in a single browser window. To re-iterate the batch-making process: first, create an empty text file. Right-click an empty space in a folder of your choosing, and select New , then Text Document.

With the text file open, enter the following script. Our example will provide the main American news media outlets available online. The above script stacks one start "" parameter on top of the other to open multiple tabs. You can replace the links provided with ones of your choosing. After you've entered the script, head to File , then Save As. Once you'd saved your file, all you need to do is double-click your BAT file.

Instantly, your web pages will open. If you'd like, you can place this file on your desktop. When you start Windows' Explorer and click the "View" menu entry, then "Options EXE from the Resource Kit , but in this case we are more interested in the print commands.

Depending on your Windows version, click the "Advanced" or "Edit" button. In the "Actions" list you should now see at least these 3 options:. Select "print" and click the "Edit" button beside or below the "Actions" list. It is the value of the field "Application used to perform action" that we are after. On most systems it will read something like this:.

EXE will look by default, we can leave it out to make the command more generic:. This command can be used to print HTML files from a batch file. Do not expect these modifications to be easy reading, though. How about PDF files, for example?



0コメント

  • 1000 / 1000