Topsy WIN7 Mklink

Source: Internet
Author: User
Tags winsxs folder

Transferred from: http://www.cnblogs.com/asion/archive/2011/03/10/1979282.html

Introduction:

Changed the new computer, finally again use on the WIN7, after a week a day to reload N times system, finally fix a decent system. Due to the proper streamlining of the WIN7SP1 official integration package using Rt7lite, the stability of the final system has to be known for a period of time. In the installation, only for the system disk (C-disk) allocated 10G of disk space, and after loading up to occupy more than 8G space, and then want to install the work software, it is obviously insufficient. So the net search method to the system to lose weight again, found a new tool WIN7 "MKLINK", can be linked to the system files or folders or connections. This is a good tool, so the function of a trial, the following is a small summary of the aftermath, to provide the necessary friends.

Basic Introduction:

Enter Mklink/? In the cmd command line to get the following help:

Creates a symbolic link.

MKLINK [[/d] | [H] | [/j]] Link Target

/d Creates a directory symbolic link. Default to File
Symbolic links.
/h creates a hard link instead of a symbolic link.
/j Create a directory join.
LINK Specifies the new symbolic link name.
TARGET specifies the path of the new link reference
(relative or absolute).

Here, I only try to create a link to the directory, so the following discussion is about the directory.

the difference between the parameter/D and/j:

In the help, the interpretation of these two parameters, one is "link", one is "join", just one word difference. I cannot delve into the literal interpretation or the theoretical interpretation at the system level, but I have to compare the differences by practice.

Use the/d parameter command to create a link:

mklink/d "Temp.link" "F:\SystemCache\Temp"

Folder properties, display:

Use the/j parameter command to create a join:

Mklink/j "Temp.link" "F:\SystemCache\Temp"

Folder properties, display:

The difference that can be seen at one glance is that "links" created with the/d parameter have one more Shortcut tab in the property.

At the same time in the cmd command line dir display directory, the display is also different,

where parameter/d corresponds to <symlinkd> and the parameter/j corresponds to <junction>. When the net search, people on the Internet notice that the Microsoft System is using <junction>

The difference between the surface is very obvious, and we are concerned about the actual operation of the process, the difference between the two? First of all we have a folder for the operation of "copy, Cut, delete", so in turn two folders to test, the results are as follows.

The test for "copy" is: Copy the two folders at the same time and paste them in the current folder, the end result is as follows:

    • A folder with the/d parameter was successfully created with a copy of TESTD in the current folder.
    • Use the/j parameter folder, copy n times, in the current folder does not have any effect, when entering the source directory, found that the copy is created in the "source directory."

Conclusion :

The usual copy operation, whether as a link or a join, is to copy the source directory instead of copying its own link or join properties. To replicate itself rather than the directory you are pointing to, you can use the method described online, which is to use xcopy with the/b parameter at the command line for replication.

The test for "cut" is: Cut two folders at the same time and paste to the D drive. The effect is as follows:

    • Folder using the/d parameter: no effect.
    • Folder with/j parameter: the "Join folder" of the current disk is deleted, but a normal folder with the same name is created in the D drive, and there are no files in the folder.

Conclusion:

For a linked folder, you cannot cut it. The linked folder can be moved, but it doesn't know what it means. (The test of the post-join folder is not very rigorous, leave it to a good friend)

"Delete" test: (re-created) right-click on two folders directly to delete.

    • Folder using the/d parameter: The current link folder is deleted and the source directory is not affected.
    • Folders using the/j parameter: The current Join folder is deleted and the source directory is not affected.
Official use:

It took a lot of time to introduce the difference between the two parameters, which may be a bit redundant, but there are some intuitive references to what parameters to use when actually deciding which one to create. I personally use the/d parameter here, because it has a "shortcut" tab to facilitate "Open folder location", that's all.

There are also many articles on how to use Mklink to transfer the location of Win7 folders, you can refer together:

1. Move the location of the user folder in Windows 7/vista 2. Win7/vista skillfully using Mklink.exe to realize the partition storage of system and user files

3. Move the WinSxS folder location in Windows7

Here also need to use a small tool: Pendmoves.zip, its decompression into the system disk System32, can be arbitrarily called in the cmd command line, of course, you can also direct CD into the unpacked folder, and then use can.

    • ㈠: The Temp folder of the mobile system.

This folder I think is more secure, at least the failure of the operation will not cause a system crash.

Within the system there are two temp variables, one is the user temp variable, and the other is the system temporary variable. The first is to follow the reference link 3 inside the ideas learned, to carry out the file transfer. Create a new link using the following code:

@mklink/d "C:\Users\Administrator\appdata\local\temp.link" "F:\SystemCache\Temp"

@mklink/d "C:\Windows\Temp.link" "F:\SystemCache\Temp"

Then you use the MoveFile tool inside the pendmoves to rename or delete the folder after the reboot.

@movefile "C:\Users\Administrator\appdata\local\temp" ""
@movefile "C:\Users\Administrator\appdata\local\temp.link" "C:\Users\Administrator\appdata\ Local\temp "

@movefile "C:\Windows\Temp" ""
@movefile "C:\Windows\Temp.link" "C:\Windows\Temp"

Because it is a temporary file, the first sentence is to delete the folder directly, and then rename the established link to temp.

    • ㈡: Transfers the user AppData folder data.

The point here is that I'm not transferring the entire administrator directory, but only the AppData folder inside. There are two reasons, one is I do not need to save the Administrator root folder dat files, two is the directory contains many folders are also joined folder. Once the entire folder is transferred, from the above differences, we know that the symbol itself will not be able to replicate a copy by normal, which may cause unknown system problems. I then moved the individual folders under the AppData directory.

Similarly, because there are several folders in the local folder under the AppData directory, they are separated separately and transferred separately.

The first step: Copy all the files under local Microsoft folders, Locallow and roaming to the target path (you may need to get "administrator rights" here, please search the Web.) )

Step Two: Then execute the corresponding code to transfer .

The following is the corresponding transfer batch code under AppData, with no special folders:

@mklink/d "C:\Users\Administrator\AppData\LocalLow. Link" "F:\SystemCache\LocalLow"

@movefile "C:\Users\Administrator\AppData\LocalLow" "C:\Users\Administrator\AppData\locallowmoved"
@movefile "C:\Users\Administrator\AppData\LocalLow.link" "C:\Users\Administrator\AppData\LocalLow"

@mklink/d "C:\Users\Administrator\AppData\Roaming. Link" "F:\SystemCache\Roaming"

@movefile "C:\Users\Administrator\AppData\Roaming" "C:\Users\Administrator\AppData\roamingmoved"
@movefile "C:\Users\Administrator\AppData\Roaming.link" "C:\Users\Administrator\AppData\Roaming"

The following is the transfer code for the Local folder under the AppData directory, only for Microsoft folders.

@mklink/d "C:\Users\Administrator\AppData\Local\Microsoft. Link" F:\SystemCache\Local\microsoft "

@movefile "C:\Users\Administrator\AppData\Local\Microsoft" "C:\Users\Administrator\AppData\Local\ Microsoftmoved"
@movefile "C:\Users\Administrator\AppData\Local\Microsoft. Link" "C:\Users\Administrator\AppData\Local\ Microsoft"

    • ㈢: Transfer the Microsoft folder under the Programdata directory.

The first step: Copy all the files from the Microsoft folder to the target path; (You may need to get "administrator rights" here, please search the Web.) )

Step two: Then execute the corresponding code to transfer

@mklink/d "\ProgramData\microsoft.link" "F:\ProgramData\Microsoft"

@movefile "C:\ProgramData\Microsoft" "C:\ProgramData\MicrosoftMoved"
@movefile "C:\ProgramData\Microsoft.link" "C:\ProgramData\Microsoft"

    • ㈣: Transfer Program Files folder.

personal experience: after the entire transfer of this folder, the "cloud" will not capture the cache properly. That is, unable to complete the manual installation to the cloud, can be used, but not normal!

So, there are two versions available here. The first step in all versions is to copy all the files in the folder to the destination path.

Entire Directory transfer:

@mklink/d "C:\Program files.link" "D:\Program Files C"

@movefile "C:\Program Files" "C:\Program files Moved"
@movefile "C:\Program files.link" "C:\Program Files"

Separate transfer:

@mklink/j "C:\Program Files\Common Files" "D:\Program Files C\common Files"
@mklink/j "C:\Program Files\installshield installation Information" "D:\Program Files C\installshield Installation Information "
@mklink/j "C:\Program files\internet Explorer", "D:\Program Files c\internet Explorer"
@mklink/j "C:\Program files\reference Assemblies" "D:\Program Files c\reference Assemblies"
@mklink/j "C:\Program files\windows Defender" "D:\Program Files c\windows Defender"
@mklink/j "C:\Program files\windows Journal" "D:\Program Files c\windows Journal"
@mklink/j "C:\Program files\windows Mail" "D:\Program Files c\windows Mail"
@mklink/j "C:\Program files\windows Media Player" "D:\Program Files c\windows Media Player"
@mklink/j "C:\Program files\windows NT" "D:\Program Files c\windows NT"
@mklink/j "C:\Program files\windows Photo Viewer" "D:\Program Files c\windows Photo Viewer"
@mklink/j "C:\Program Files\Windows Portable Devices" "D:\Program Files c\windows Portable Devices"

Description : Because there are many directories in this folder, and as the number of individual installed software is different, it is generally not recommended to transfer this folder .

Additional additions:

Once you have created a task plan using MoveFile, you can use Pendmoves to check the total number of tasks created. One additional thing to add here is that when you create a plan that is wrong, such as movefile using the wrong path , or if you want to cancel the movefile plan , you can use the following method:

Open the registry, find the path "hkey_local_machine\system\controlset001\control\session Manager", delete "PendingFileRenameOperations" The value is available.

Here is the official rationale: Http://technet.microsoft.com/en-us/magazine/2009.06.utilityspotlight.aspx

However, the registry path explained in the table is inaccurate.

Related documents download: Mklink's magical. Zip

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.