' *****************************************************************************
' TEST SCRIPT - movefavorite.vbs
' *****************************************************************************
' 作用: 修改并移动用户收藏夹路径
' 作者: brinkman
' 日期: 11:21 2010-04-16
' Copyright (c) SunWill
' *****************************************************************************
Option Explicit
'取得当前用户名称
Dim username
username=CreateObject("Wscript.Shell").ExpandEnvironmentStrings("%username%")
'定义收藏夹根位置
Dim sPath
sPath="D:\SunWill\"&username&"\Favorites"
'修改注册表中收藏夹位置
Dim OperationRegistry
Set OperationRegistry=WScript.CreateObject("WScript.Shell")
OperationRegistry.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites",sPath,"REG_EXPAND_SZ"
'移动收藏夹位置
On Error Resume Next
Const OverwriteExisting = True
Dim WshSysEnv,UserProfilePath,objFSO
set WshSysEnv = CreateObject("Wscript.Shell").Environment("PROCESS")
UserProfilePath = WshSysEnv("userprofile")
set objFSO=CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder sPath
objFSO.CopyFile UserProfilePath & "\Favorites\*" , sPath&"\", OverwriteExisting
objFSO.CopyFolder UserProfilePath & "\Favorites\*" , sPath&"\", OverwriteExisting
阅读(1269) | 评论(0) | 转发(0) |