Use NET command to make LAN files batch update _ Web surfing

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:

NET use S: \\computer-01\D
Attrib-s-h-r s:\ghostc:\windows\command\xcopy.exe/s/e/y
D:\ghost S:\ghost
NET use */delete
NET use S: \\computer-02\D
Attrib-s-h-r S:\ghost
c:\windows\command\xcopy.exe/s/e/y D:\ghost S:\ghost
NET use */delete
Write a description of the use of the Net command, which uses 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.

   one. Command resolution.

1.net Use S: \\computer-01\D

(The COMPUTER-01 shared disk D disk is connected to the network and mapped to the network drive disk s disk.) Here D disk to do a full share, if not the full share of the file on the copy does not pass, then do not play the kitchen knife after me ^ ^.

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-01\D
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:\windows\command\xcopy.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; prompt 2:/s
/e parameter means to copy all subdirectories under ghost including empty directories. /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-01\D * * *
Attrib-s-h-r S:\netgames\mir
C:\WINDOWS\COMMAND\Xcopy.exe D:\netgames\mir S:\netgames\mir
NET use */delete

Tip: 1. There's no use here./s/e is just copying files in the Mir root directory without copying the entire directory

2. We can also insert a sentence before Xcopy c:\windows\command\del/y
S:\netgames\mir\*.*

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-01\hitsoft * * *
Attrib-s-h-r S:\netgames
C:\WINDOWS\COMMAND\Xcopy.exe C:\program~1\hitsoft\netgames
S:\NETGAMES/S/y/e
NET use */delete

Hint: We can do more, and delete directories, just convert xcopy to deltree.

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.