Win7:如何部署定製的Quicklaunch表徵圖的更正-更新
使用Regedit輸出的reg檔案,不是純文字檔案!所以需要處理一下,才能使用Replace.vbs指令碼來替換其中的字串。這個步驟可以在Make.cmd檔案中完成。
只是增加了幾行代碼:
:: ---------------------------------------------------------------------------------------:::: Make.cmd for Quicklaunch Win7:: :: Description::: After admin make quick launch icons done in current user, this cmd will copy all the nessary info:: to correct folder to be ready for deployment.:: This cmd must be run on the user who make all the icons ready and map to local drive if it is saved:: on network share folder.:::: History::: Oct 25, 2012:::: Copyright (c) 2012, Tony Liu':::: This program is free software; you can redistribute it and/or:: modify it under the terms of the GNU General Public License:: as published by the Free Software Foundation; either version 2:: of the License, or (at your option) any later version.:::: This program is distributed in the hope that it will be useful,:: but WITHOUT ANY WARRANTY; without even the implied warranty of:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the:: GNU General Public License for more details.:::: You should have received a copy of the GNU General Public License:: along with this program; if not, write to the Free Software:: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.:::: Contact: Tonyliu2ca@gmail.com:: ---------------------------------------------------------------------------------------%~d0cd %~d0%~p0del Shortcuts\*.*del TempRegs\*.*xcopy "%USERPROFILE%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\*.*" .\Shortcuts\ /Y /I /E /R /H /Q /Creg export HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband .\TempRegs\Tmp.reg /ytype .\TempRegs\Tmp.reg > .\TempRegs\Taskband.regcscript Replace.vbs .\TempRegs\Taskband.reg "[HKEY_CURRENT_USER\" "[HKEY_USERS\TempHive\"del .\TempRegs\Tmp.reg
另外,原來的Replace.vbs雖然直觀簡單,不過如果是大檔案,還是不適合,所以使用下面的比較好(注1):
If WScript.Arguments.Count <> 3 then WScript.Echo "usage: Find_And_replace.vbs filename word_to_find replace_with " WScript.Quitend IfFindAndReplace WScript.Arguments.Item(0), WScript.Arguments.Item(1), WScript.Arguments.Item(2)WScript.Echo "Operation Complete"function FindAndReplace(strFile, strFind, strReplace) Set objFSO = CreateObject("Scripting.FileSystemObject") Set objInputFile = objFSO.OpenTextFile(strFile,1) strTempDir = objFSO.GetSpecialFolder(2) Set objTempFile = objFSO.OpenTextFile(strTempDir & "\temp.txt",2,true) do until objInputFile.AtEndOfStream objTempFile.WriteLine(Replace(objInputFile.ReadLine, strFind, strReplace)) loop objInputFile.Close Set objInputFile = Nothing objTempFile.Close Set objTempFile = Nothing objFSO.DeleteFile strFile, true objFSO.MoveFile strTempDir & "\temp.txt", strFile Set objFSO = Nothingend function
注1: http://stackoverflow.com/questions/1975321/find-and-replace-string-in-my-text-with-vbscript