Use Net command to synchronize LAN files to batch update _dos/bat

Source: Internet
Author: User
Tags net command
Now everyone wants to have a sync software to meet the network directory or file updates to reduce their workload, now there are a lot of software on the network to achieve this goal, such as synchronization experts, but these software needs to install the server and client, the client to resident to use, and occupy a certain amount of resources.

The following batch uses NET commands to update files and directories synchronously. The advantage is that any machine can do the server and the client, and does not occupy any resources. Of course, the disadvantage is to write batch processing a bit annoying ^ ^.

I first write the batch and then explain it in detail:

Copy Code code as follows:
NET use s:computer-01d
Attrib-s-h-r s:ghostc:windowscommandxcopy.exe/s/e/y
D:ghost S:ghost
NET use */delete
NET use s:computer-02d
Attrib-s-h-r S:ghost
c:windowscommandxcopy.exe/s/e/y d:ghost S:ghost
NET use */delete

Write a description of the use of the Net command, where the net command one of the parameters net use, if interested in other, you can play net/in command Window? Displays its help screen.

Parameter net use

Role: Connect the computer or disconnect the computer from the shared resource, or display the connection information for the computer.

Command format: NET USE [DeviceName | *] [Computernamesharename[volume]]

[Password | *]] [/user:[domainname]username] [[/delete] |

[/persistent:{yes | no}]]

Parameter introduction:

Type net use with no parameters to list network connections.

DEVICENAME Specifies the name of the resource to which you want to connect or the name of the device to disconnect.

Computernamesharename the name of the server and the shared resource.

Password The password to access the shared resource.

* Prompt to type password.

/USER Specifies a different user to connect to.

domainname specifies another domain.

USERNAME Specifies the user name for the login.

/home connects users to their host directory.

/delete Cancel the specified network connection.

/persistent controls the use of permanent network connections.

The following is a simple example of a description:

(1) net use e:yfangtemp the Yfangtemp directory to set up e-disk

(2) net use E:yfangtemp/delete disconnect

Here I only write two lines of batch processing, meaning that the two major lines of network identity are different, others can be followed by analogy. My Internet Café Network logo is computer-01~computer-n

The network name of Internet Café Computer, can change according to own actual situation. such as User01~userxx

Begin to explain each line of command, the actual application will be explained later.

A Command resolution.

1.net Use s:computer-01d

(The COMPUTER-01 shared disk D disk is connected to the network and mapped to the network drive disk s disk.) D disk here to do full sharing, if not fully shared files will not be replicated.

Tip 1: You can set up a full shared password if you are afraid that you will be removed from the file altogether. Assuming that the remote shared disk has a fully shared password of 123, this line of command is changed as follows:

NET use s:computer-01d 123

This is no problem accessing the remote client share disk. Tip 2: Why do you want to choose the D disk instead of E disk C, is to be synchronized with the updated server letter, I would like to copy the local Machine D plate under the things, of course, and D-disk corresponding. )

2. Attrib-s-h-r S:ghost

(Delete the file attributes (read, hide, System) under the target directory under the target disk to be copied.) Three. Tip: If the destination disk does not have a ghost directory, the next xcopy command is created automatically.

3. c:windowscommandxcopy.exe/y/s/e D:ghost

S:ghost (The Ghost directory under the local machine D disk is copied to the virtual map disk under the Ghost directory, where the S disk is the D disk on the computer-01.) Tip the 1:s disk automatically disappears after the first large row is executed, and the D disk computer-02 is virtual to be mapped to S disk when the second row is executed, indicating that the 2:/s/e parameter meaning refers to all the subdirectories including empty directories under Ghost. /y Automatically overwrite existing files)

4. NET use */delete (disconnect all connections)

2. Practical Application

1. Update of the shared disk directory:

For example, now the legend of headache, I unified installed in the D-Disk under the Netgames mir directory. Share d disk fully and set the shared password to * * *. When you want to update files and plug-in files, the plug-in file is also placed in the Mir directory. This allows you to debug a computer first and then write the following commands and execute them.

NET USE s:computer-01d * * *

Attrib-s-h-r S:netgamesmir

C:windowscommandxcopy.exe D:netgamesmir S:netgamesmir

NET use */delete

Tips:

1, there is no use/s/e is to copy only the files in the Mir root directory without copying the entire directory
2. We can also insert a sentence of c:windowscommanddel/y before Xcopy S:netgamesmir*.*

Delete the files under Mir and then copy them. It is safe to write.

3.computer-01 can be written by analogy, such as computer-02-03-04 ...

2. Update of shared directory

Above we put the legendary directory files and Plug-ins updated after the good, but there is a problem. Network management software desktop icons are not synchronized updates, good deeds to the end, the last time we are the entire letter to the full share, this time we only have a directory to completely share and set the password * * *. Because I am using PUBWIN4 network management software, install C disk, for the sake of security, or only share the folder, not the whole disk. Pubwin desktop shortcuts installed in the C-disk program files under the Hitsoft, will be hitsoft completely shared, legends and Legends of the plug-in shortcut placed under the Netgames under the directory. Batch processing is as follows

NET USE s:computer-01hitsoft * * *

Attrib-s-h-r S:netgames

C:windowscommandxcopy.exe C:program~1hitsoftnetgames

S:NETGAMES/S/y/e

NET use */delete

Hint: We can do more, and delete the directory, as long as the Xcopy converted to deltree on it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.