2014-01-08

Windows 7 mklink命令詳解

mklink是Windows 7下的一個類似於linux下In的命令,其作用是在NTFS文件系統中創建文件或目錄的鏈接(類似於桌面快捷方式)。如果加以利用其發揮的作用是非常的大的,不僅可以幫助我們節省不少時間,而且可以使我們重裝系統後不再丟失用戶文件。

Mklink命令詳細介紹

Windows 7下的mklink命令通過指定參數可以建立出不同形式的文件或目錄鏈接,分為 hard link、symbolic link 和junction 三種。

1.symbolic link

  A symbolic link is like a short-cut but instead of being saved as a file it is registered to the hard drive partition. It does not use any disk space and all programs recognise both the link and the target. A symbolic link can point to any file or folder either locally on the computer or over a network using a SMB path. ( A short cut is a file that points to another file. It is an antiquated pointing system from the Windows 95 era that many programs do not recognise. Short-cuts do not only use up space on the hard drive, they also break and linger behind after the target has been deleted, renamed or moved. )

2.junction

  作用基本和 symbolic link 類似。區別在於,junction 在建立時會自動引用原文件(或目錄)的絕對路徑, 而 symbolic link 允許相對路徑的引用。A junction behaves like a hard link for directories but unlike file hard links you can create junctions that span multiple partitions. Again a directory junction and its content is stored on the hard drive partition but they do not use any additional space. Any changes to the content within either the target or the links will automatically propagate except where the target directory is deleted or renamed. In that case all hard links that point to the target will break and linger on the partition.

3.hard link

  建立一個 hard link 相當於給文件建立了一個別名,例如對1.TXT創建了名字為2.TXT的硬鏈接,若使用記事本對1.TXT進行修改,則2.TXT也同時被修改,若刪除1.TXT,則2.TXT依然存在,且內容與1.TXT一樣。 A file hard link is a little different and can not be used over multiple partitions meaning you can not have a link on drive C: pointing to a file on drive D:. A file hard link points to and duplicates a target as a mirrored copy but the copy does not use any additional space on the hard drive partition. So 2 hard links that mirrored a 1 GB file would  in total only use 1 GB on the partition rather than 3 GB. Importantly if either the hard links or the target are deleted the other links retain the data. Changes to the content of either the target or the links automatically propagate to all other items.

建立鏈接請注意:
1、建立文件或目錄鏈接限於 NTFS 文件系統,symbolic (junction) link 的建立可以跨文件系統;
2、hard link 只能用於文件,不能用於目錄,symbolic (junction) link 可以為目錄建立鏈接;
3、hard link 只能建立同一分區內的文件指向;
4、hard link 不允許對空文件建立鏈接,symbolic (junction) 可以。

Mklink的參數定義

無參數指定:建立文件的符號鏈接。無參數指定的默認情況下,建立的是文件的符號鏈接,刪除鏈接文件不會影響源文件,
/d:建立目錄的符號鏈接符號鏈接(symbolic link)
/j:建立目錄的軟鏈接(聯接)(junction)
/h:建立文件的硬鏈接(hard link)

命令格式:mklink /d(定義參數) \MyDocs(鏈接文件) \Users\User1\Documents(原文件)

最後,至於刪除建立的鏈接,跟刪除文件一樣使用」DEL」命令。

Mklink命令用途

轉移系統中的用戶設置文件

  Windows 7中將用戶設置與系統文件分離, 所有的用戶設置及用戶文件都存儲在C盤下的User目錄 (在中文版Windows 7中顯示為「用戶」目錄), 重裝系統後所有的系統設置及用戶文件都會消失。

  Windows 7安裝完成後可以將C盤下的User目錄轉移到非系統分區,如D盤,這樣,重裝系統後只要重新將C盤下的User目錄鏈接到D盤即可。我們在創建鏈接後系統在訪問C:/User目錄其實是在訪問D:/User目錄。

命令如下:

1.複製User目錄到D盤 : robocopy 「C:\Users」 「D:\Users」 /E /COPYALL /XJ
2.強制刪除User目錄 : rmdir 「C:\Users」 /S /Q
3.創建C盤下的User的軟件鏈接,鏈接到D盤User目錄:mklink /J 「C:\Users」 「D:\Users」

重裝系統後只需重覆第二條和第三條命令及可

有了這條命令就再也不怕重新系統了

2014-01-02

Task Scheduling Error : Event 100, Bonjour Service

暫時解法 :

Solution 1 : 解除安裝 Bonjour 服務.

Solution 2 : Adrian said : Apparently you can ignore this as the Bonjour service (used by iTunes) is quick to record it anytime it "thinks" it experiences an unreasonable delay. If you don't want the event in your logs, you can disable Bonjour (open Services, find Bonjour Service in the list, stop it and change the startup type to "Manual" or "Disabled").

Source: http://www.eventid.net/display-eventid-100-source-Bonjour%20Service-eventno-10659-phase-1.htm

The "Task Scheduling Error" type of problems seem to be a common issue on Windows 7 64 bit. Several users ended up stopping the service in order to avoid the logs being filled with these errors. They would only start the service when needed (iTunes needs this service in order to run properly).
From our experience, iTunes will start regardless of the status of the Bonjour service, however a warning is displayed saying that Bonjour is needed to access shared libraries. The warning will only be shown once so it won't bother you every time iTunes is started. In iTunes Preferences, the Sharing tab will display a message saying that the Bonjour service is required in order to use this feature.

 

安裝 iTunes 之後, 事件檢視器中, 持續出現類似以下的錯誤:

Task Scheduling Error: Continuously busy for more than a second
Task Scheduling Error: m->NextScheduledEvent 7004
Task Scheduling Error: m->NextScheduledSPRetry 7004

2014/01/02 : 嘗試於 AP 防火牆中 disable “Filter multicast”. (還是會發生)

2014/01/04 : AP disable “Filter multicast” 之後, 仍然會發生 Event 100 ERROR; 決定解除安裝 Bonjour, and enable “Filter multicast” again. 觀察後續 iTunes 和 iPhone 搭配使用上是否會有問題.

2014/01/09 : 解壓縮 iTunes64Setup.exe 之後, 單獨安裝 Bonjour64.msi. 再觀察看看.(還是會發生)

2014/01/11 : 改變 Windows 防火牆-進階設定-輸入規則-Bonjour 服務 設定 : 4 rules –> 2 rules. .(還是會發生)
原本 : 設定檔(公用)+程式(32 bits or 64 bits mDNSResponder.exe)+通訊協定(TCP or UDP)
新版 : 設定檔(任何)+程式(32 bits or 64 bits mDNSResponder.exe)+通訊協定(任何)

2014/01/11 19:16 : disable AP DD-WRT SPI firewall .(還是會發生)

2014/01/12 05:32 改變網路卡電源管理, 允許電腦關閉這個裝置以節省電源 : Enabled->Disabled (還是會發生)

2014/01/12 09:20 將 iPod 服務由手動改為自動, Bonjour 服務防火牆設定如下 [不是我設的, 系統自己變成這樣] : (還是會發生)

2014/01/15 04:58 關閉 Windows Firewall ( Testing … )

2014/01/17 03:34 mDNSresponder.exe 改用 x86 版.(還是會發生)

2014/01/17 06:47 改變省電時間設定 ( 10/30 –> 20/20 ) .(還是會發生)

2014-01-12_174052

備註 1 : Bonjour 服務需要 UDP port 5353
Bonjour_Firewall
備註 2 : 需要 Bonjour Service 才能和其他使用者共享音樂, 透過 AirPlay 揚聲器播放音樂, 連接 Apple TV 和使用 iPhone 和iPod touch 遙控器. (目前我似乎用不上)
備註 3 : iTunes64Setup.exe 實際上是一個壓縮檔, 可用 7z.exe 解壓縮.