Delete a banner using Kaspersky WindowsUnlocker
Today, the removal of ransomware viruses has become somewhat more complicated than before - many time-tested methods do not work. For example, now it’s unlikely that you can unblock a…

Continue reading →

Work on the Windows command line
The most common startup recommendations are: Start, Run, cmd. There is a Run item in the start menu. He runs a program that allows you to transfer single commands to the…

Continue reading →

Why does the computer not see the USB flash drive? 8 reasons
Sometimes at the most inopportune moment, when it is urgent to remove information from a USB flash drive to a PC, the computer refuses to see the new device. It…

Continue reading →

Bat files, examples

You can perform all the examples published below not only by creating and running a BAT file containing these commands, but also copying them directly to the command line.

To open the command line in the right place (in the folder with files, for example), you need to call the context menu (RMB) with the Shift key held down:

command line call

You can read about how to work with the command line in this article. We pass directly to the teams.

A list of all console commands with a description can be obtained by typing help in the console
Help for any command can be obtained using the /?
For example: DIR /? displays help for all keys of the DIR command

Delete temporary files before shutting down your computer
I think everyone at least heard about sms viruses or came across them personally. The bat-file will help you to shut down the computer correctly by deleting temporary files, the folder with which the virus usually loads.

At the next boot of the device (at an early stage), the virus makes entries in the registry, disrupting the normal operation of the system. And when the desktop boots, the situation is more difficult to fix.

Of course, not all viruses work according to this scheme, but nevertheless, clearing temporary files and the system cache before shutting it down significantly reduces such risks.

start / wait “” “C: \ Program Files \ CCleaner \ CCleaner64.exe” / auto
start / wait “” “C: \ WINDOWS \ System32 \ shutdown.exe” / s / t 10
CCleaner is not installed by default on Windows. It needs to be installed separately. You can download the installer on the developer’s website.

The CCleaner program starts first and deletes all temporary files on the computer. Then the computer shutdown program starts with a delay of 15 seconds to avoid possible conflicts with CCleaner.

You must create a .bat file and copy this example into it. Display the shortcut to the bat-file on the desktop, assign it a beautiful icon and turn off the computer using this shortcut-button.

Get a list of files in a folder using a bat file
I periodically use bat-files to get lists of files in folders. A frequent situation: for work, clients send an archive with photos from the photographer. Photos are named according to the article numbers.

There is no textual information accompanying the photograph. You need to make a list based on the photos sent and import it into the product catalog on the site. For each product, several photos were taken. They are named like this:

Photo of the product with the article A1234.jpg
Photo of the product with the article A1234 (2) .jpg
Product photo with article B1234.jpg
Photo of the product with the article B1234 (2) .jpg
First, I get a list of all the files in the folder with the following command:

dir * .jpg / B / L> filelist.txt
The * .jpg command will allow only JPG files to be considered when compiling a list. The / B switch allows you to get a list containing only the names of the files in the folder. The / L switch will print all lowercase names. The command> filelist.txt will create a text file named filelist and write the result there.

The next step is to get rid of duplicates, so that only one entry is left in the list for each product:

type filelist.txt | findstr / I / V “(2)”> temp.txt
The findstr command will search the previously received file. The / I switch allows you to search for case insensitive entries, and the / V switch records lines that do not match the match. The quotation mark indicates the string whose coincidence you want to fix. And the last command> temp.txt will write to the temp file all the results that do not contain the name “(2)”. As a result, I get:

Photo of the product with the article A1234.jpg
Product photo with article B1234.jpg
And further on the basis of this text list I will prepare a file for import.

If you need to carry out the opposite operation – output only matches to the temp.txt file, then you will not find the needed one in the list of commands (findstr /?). There is only an inverse filter by exact match – / X.

For this task, you can use the command to output line numbers / N in which there are matches (numbers are displayed together with the line):

type filelist.txt | findstr / I / N “(2)”> temp.txt
The main thing when working with text information (text files) is to remember one thing:

If for text operations you use a file that you did not create through the command line as the source, it must be in the encoding that is understood by the command line. For example, CP1251 (ANSI).

Otherwise, you run the risk of getting something like this:

wrong encoding

Copy directory tree without files
When I start making new projects, it becomes necessary to get a directory tree similar to the old project tree with the difference that there should not be any files in it. For a new project, it is easier to add 3-5 files to the desired empty folders than to copy an existing project and then delete the unnecessary from there.

To get a directory tree without files, use the following command:

xcopy folder_1 folder_2 / T / E
The xcopy command takes as a basis the directory tree at folder_1 and creates a copy of it in the folder folder_2.

How to choose a service on the Internet
Nowadays, electronic gadgets are firmly in use, and with them the Internet. There, according to the trend of the time, the service sector is also moving. Even in my small…

...

How to protect your password from hacking
Today, passwords play a significant role in human life. Everywhere on the Internet, on every site, each account must have its own password in order for the user to gain…

...

A bit about CCTV systems
When it comes to business security, peace of mind for the life and health of relatives, it is necessary to carefully approach the choice of security system. Over the past…

...

Creating BAT files
People who are familiar with the term batch file know that BAT files can significantly simplify life and save time if you can write and use them correctly. In this…

...