Um, you click on it?
I think you’re actually asking how to create and then run a batch file. That’s easy.
It’s also pretty old-school, as Microsoft is pushing everyone towards the much-more-powerful, but much-more-complicated, PowerShell environment instead.
But batch files still work fine In Windows 10; they’re still useful for quick task automation; and they’re very, very easy to set up.
There’s no magic to it: A batch file is just a list (or “batch”) of commands assembled into a regular, plain-vanilla text file, but saved with the extension .bat instead of .txt.
That’s all there is to it: A .bat file extension tells Windows that whatever text is inside the file should be treated as a series of system commands to run; rather than text to be displayed and read.
Here’s an ultra-easy “Hello World!” example you can try. It’ll take maybe two minutes, start to finish, even if you’ve never created a batch file before:
Open Notepad.exe (e.g. type notepad in the cortana/search box; select the app when it appears).
Enter the batch of commands you want your PC to carry out, one command per line. In this example, we’ll just use five simple commands. (There are actually over 250 commands available!) Type (or copy/paste) the following:
echo off
cls
echo Hello World!
pause
exit
(Echo off tells the command processor not to display (“echo”) the commands it’s working on; cls clears (erases) any previous command window content; echo Hello World! displays the phrase “Hello World” in the command window; pause tells the command processor to wait for input (it automatically generates a “Press any key to continue…” message;) and exit tells the command processor that the batch file is at an end, and to close the command window.)
Don’t save the file yet: By default, Notepad will save in text file format (.txt), not in runnable batch file (.bat) format.
When you’re ready to save, click File/Save As, and then select All files from the Save as type option. Give your your file any name you wish, but then type a .bat after the name (e.g. test.bat or helloworld.bat or whatever), and then click Save to whatever location you’ve chosen.
To run the batch file, just double-click on the file you created; a command window will open with the text, “Hello World!” inside. You’ll see a notice to “Press any key to continue…;” and when you do press a key, the window will close.
It’s really that simple: For quick-and-dirty task automation, just create a text file with a .bat extension, and you can invoke virtually any of the 250+ Windows commands available.
Permalink: https://langa.com/?p=2813
COMMENT / QUESTION on THIS ITEM? See the Comment box at bottom of this page!
NEW QUESTION? Ask here!
(Want free notification of new content? Click here!)