Shopping Product Reviews

Work with batch files in Windows

These small files can save time and effort by automating actions that would otherwise be done manually. It does seem like something of a dark art though, as I don’t know many techies who can write good ones. There is nothing I like more than a challenge! The first thing to remember is that batch files can be as simple or as complex as you want or need them to be. They can take a lot of the work out of server maintenance and even help with normal desktop tasks.

Making one is pretty easy, just use notepad and save it as a .bat file. So why does it look like black magic?

The neatest way to play around is to create a folder somewhere and call it something useful like “BatchFiles”. I’ll leave the exact settings up to you, but create this file, then create an empty notepad file inside the folder. Call it what you want, mine is imaginatively titled “batch1”.

I have created two batch files for my gaming machine. It is a simple alternative to using hardware profiles. One to minimize services and other system drains while gaming, and the other to restore original settings. I’ll demonstrate how to create this later, but for now let’s go back to the 1980s.

Write this in notepad;

@ECO OFF

ECHO.

ECHO

HuxleyTech is the best!

ECHO.

PAUSE

CLS

EXIT

Save it as Batch1.bat, making sure to remove the .txt suffix. Double click the file and see what happens.

Now this is an entry level batch script, but it gives you an idea of ​​how they work.

ECHO OFF will not show anything when the script is executed.

ECHO. It will show a blank line.

ECHO displays the text that follows.

CLS cleans the screen

The output should really speak for itself… You can do all sorts of things with these files, and the scope is way beyond this article. However, I will show you how to create a basic file to start and stop Windows services. This is the base of my “Games.bat”.

The two commands you’ll need are generic to Windows;

NET START and NET STOP. These commands start and stop Windows services. For example.

NET STOP “Messenger” will stop the Messenger service from running. understandably

NET START “Messenger” will start it again. I have many of the Windows services disabled or “manualized” as default anyway, so this list may not reflect your own settings. Some adjustments to your own specifications will be needed here.

So my Games.bat looks like this; NET STOP “Alert” NET STOP “Application Layer Gateway Service” NET STOP “Cryptographic Services” NET STOP “DNS Client” thinner and meaner gaming machine. A second batch file called “Normalise.bat” looks a bit like this;

NET START “Alerter” NET START “Application Layer Gateway Service” NET START “Cryptographic Services” NET START “DNS Client” To make your job a little easier, you can export a list of services to use in this file. Go to Control Panel, Administration Tools, Services. Select the Action menu and then Export. You decide the format…

The next one is quite useful as it asks for a password for a folder. Once you create it in notepad, you need to insert your own password and the designated folder directory in the proper place. There are three places where you need to enter information, marked with ***. Where it says ENTER PASSWORD, this is where you enter the password you want to use. For example; “Set password = Huxley.”

@echo off

title password protection

color 0a

set / one try = 3

set password=***ENTER PASSWORD***

:upper part

echo.

echo ———————————————–

echo.

echo folder password

echo.

echo ———————————————–

echo You have %tries% attempts left.

echo Enter the password

echo ———————————————–

set /p pass =

if %pass%==***ENTER PASSWORD*** (

go to correct

)

set /a attempts=%attempts -1

if %try%==0 (

go to penalty

)

cls

go upstairs

:penalty fee

echo Sorry, too many wrong passwords, closing.

start shutdown -s -f -t 35 -c “STARTED SHUTDOWN”

pause

exit

:Right

cls

echo ———————————————–

echo Password accepted!

echo.

echo Opening Folder…

echo ———————————————–

explore ***ENTER FOLDER PATH HERE***

pause

The last input required is the folder path. For example, “explore c:/My Documents/Stuff”.

Batch files are a huge topic, and I’ve only scratched the surface here. I can go into a little more detail at another time.

Leave a Reply

Your email address will not be published. Required fields are marked *

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1