Win7:如何部署定制的Quicklaunch图标-更新
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