Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What kinds of bat are commonly used in batch processing

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "which batches are often used in bat". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Batch processing of C disk conversion to NTFS format

The code is as follows:

@ ECHO OFF

@ ECHO.

@ ECHO. State clearly

@ ECHO--

The @ ECHO NTFS format is the recommended format for WinXP. Converting to NTFS format can improve the performance of hard disk storage.

@ ECHO efficiency, and access permissions can be set to protect files. But the partition in NTFS format is in DOS/WIN9X

None of them can be recognized under @ ECHO, which may cause inconvenience to beginners. Please do not change if it is not necessary.

@ ECHO--

@ ECHO.

Convert c:/fs:ntfs

Several dangerous commands in batch processing

1. FORMAT disk format command

Because the FORMAT command formats the used disk so that all files on the disk can be deleted, you should use the DIR command to check whether the contents on the disk need to be retained before using this command. In addition, care should be taken to prevent the disk from being mistakenly formatted due to command input errors.

2. DISKCOPY disk copy command

When this command is copied, regardless of whether the destination disk has stored information or not, the destination disk will be reformatted to the same format as the source disk. Therefore, when using this command, on the one hand, we should check whether there are useful files on the destination disk, and on the other hand, we should prevent the source disk from being mistaken and formatting the source disk. The source disk can be write-protected before copying.

3. BACKUP disk backup command

Before using this command, if you do not use the parameter / A, the original file on the destination disk will be deleted. Therefore, before backing up, you should check whether the contents of the destination disk are useful, or use the parameter / A for backup.

4. DEL delete file command

Because this command can use the wildcard characters * and? To delete a batch of files, in order to avoid mistakenly deleting a large number of files, it is recommended to use the DIR command to check whether the deleted files are correct before using this command. Then execute this order.

5. COPY file copy command

Since the COPY command will overwrite the original file with the same name on the destination disk when copying the file, when naming the destination file name, it should be guaranteed not to have the same name as the original file on the destination disk.

Add ms-dos to the right

Some tools are in command line mode (CLI). Every time you run into cmd, it is not troublesome to enter the folder where the tool is located. Let me tell you a simple way to make windows access to CLI at any time like linux.

Open the registry editor, find HKEY_CLASSES_ROOT\ Directory\ shell, select it, right-click, create a new primary key, name it "DOS", then select the newly created primary key, double-click the default string value on the right, enter "go to DOS window" in the pop-up dialog box, select the new primary key, create a primary key, name it "command", and select the "command" primary key. Change the default value to "cmd.exe / k" cd% L "".

Note: "cd% L" is entered into the current folder.

Just end the explorer.exe in the task manager, then run explorer.exe, and the settings will take effect. There's no need to restart.

Now right-click a folder to see if "go to DOS window" appears in the key. In this way, you can open ms-dos anytime and anywhere, and it's not as troublesome as before.

The use of the batch command shift

In DOS batches, only 9 command-line parameters are supported (% 0 is used to represent the command itself). If you want your batch to support more than 9 command-line parameters, you need to use the shift command. Every time you run the shift command, the command-line parameters move one bit to the left, that is,% 2 becomes% 1,% 3 becomes% 2, and so on. In a simple example, you create a batch, hypothetically named tstshift.bat, with the following content:

@ echo off

Echo 0

Echo 1 2 3 4 5 6 7 8 9

Echo 1

:: 1

Shift

Echo 1

:: 2

Shift

Echo 1

:: 3

Shift

Echo 1

:: 4

Shift

Echo 1

:: 5

Shift

Echo 1

:: 6

Shift

Echo 1

:: 7

Shift

Echo 1

:: 8

Shift

Echo 1

:: 9

Shift

Echo 1

:: 10

Shift

Echo 1

Then run:

The running results of tstshift 0 1 2 3 4 5 6 7 8 9 an are as follows:

D:\ > tstshift 0 1 2 3 4 5 6 7 8 9 a

Tstshift

0 1 2 3 4 5 6 7 8

0

one

two

three

four

five

six

seven

eight

nine

An above is the function supported by all shift commands, and the shift function under 2000/xp/2003 adds a / n parameter to specify that the shift starts from the nth parameter. The Chinese help for the shift command under 2000/xp/2003 is:

D:\ > shift /?

Change the location of replaceable parameters in the batch file. SHIFT [/ n] if the command extension is enabled, the SHIFT command supports the / n command line switch, which tells the

The command shifts from the nth argument; n is between zero and eight. For example: SHIFT / 2 shifts% 3 to% 2,% 4 to% 3, and so on; and does not affect% 0 and% 1.

This is the end of the content of "which batches are often used in bat". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report