|
本帖最后由 QQ25808181 于 2011-9-22 10:24 编辑
帮忙完善个一下这个脚本!
要求修必后,并自动移动目录下的文件到修改后的目录下面!
还有,能不能加一个进度条,等等,
代码如下,我是新手,请帮下忙!谢,,,
; 系统文件夹修改路径,windows xp 中已测试!
;*********************************************
Local $_userdata=InputBox("系统文件夹路径修改","请输入存放的目录:","D:\userdata","",1,1)
If @error Then Exit
;*********************语句部份*******************************
_DirCreate_userdata ($_userdata)
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\LocalizedResourceName","@shell32.dll,-3838","REG_SZ","用户数据")
_write_hkcc($_userdata)
_write_hku($_userdata)
_write_common($_userdata)
MsgBox(0, "系统文件夹修改", "已将系统文件夹修改至:"&$_userdata&" 目录下面")
exit
;*******************语句结束部份*****************************
;*******************以下为函数部份*****************************
;**************************************************************
Func _DirCreate_userdata ($_userdata) ;建立相关文件夹
If Not FileExists ($_userdata) Then
DirCreate($_userdata)
FileSetAttrib($_userdata,"+R+S+H")
FileWrite($_userdata&"\Desktop.ini","[.ShellClassInfo]"&@crlf&"IconFile=%SystemRoot%\system32\SHELL32.dll"&@crlf&"IconIndex=80"&@crlf&"LocalizedResourceName=@shell32.dll,-3838")
FileSetAttrib($_userdata&"\Desktop.ini","+S+H")
DirCreate($_userdata&"\Favorites")
DirCreate($_userdata&"\桌面")
DirCreate($_userdata&"\My Documents")
DirCreate($_userdata&"\All Users")
DirCreate($_userdata&"\All Users\Documents")
FileWrite($_userdata&"\All Users\Documents\Desktop.ini","[.ShellClassInfo]"&@crlf&"LocalizedResourceName=@shell32.dll,-21785")
FileSetAttrib($_userdata&"\All Users\Documents\Desktop.ini","+S+H")
DirCreate($_userdata&"\All Users\Documents\My Videos")
FileWrite($_userdata&"\All Users\Documents\My Videos\Desktop.ini","[.ShellClassInfo]"&@crlf&"InfoTip=@Shell32.dll,-12690"&@crlf&"IconFile=%SystemRoot%\system32\SHELL32.dll"&@crlf&"IconIndex=-238"&@crlf&"LocalizedResourceName=@shell32.dll,-28996")
FileSetAttrib($_userdata&"\All Users\Documents\My Videos\Desktop.ini","+S+H")
DirCreate($_userdata&"\All Users\Documents\My Pictures")
FileWrite($_userdata&"\All Users\Documents\My Pictures\Desktop.ini","[.ShellClassInfo]"&@crlf&"InfoTip=@Shell32.dll,-12688"&@crlf&"IconFile=%SystemRoot%\system32\SHELL32.dll"&@crlf&"IconIndex=-101"&@crlf&"LocalizedResourceName=@shell32.dll,-28997")
FileSetAttrib($_userdata&"\All Users\Documents\My Pictures\Desktop.ini","+S+H")
DirCreate($_userdata&"\All Users\Documents\My Music")
FileWrite($_userdata&"\All Users\Documents\My Music\Desktop.ini","[.ShellClassInfo]"&@crlf&"InfoTip=@Shell32.dll,-12689"&@crlf&"IconFile=%SystemRoot%\system32\SHELL32.dll"&@crlf&"IconIndex=-237"&@crlf&"LocalizedResourceName=@shell32.dll,-28995")
FileSetAttrib($_userdata&"\All Users\Documents\My Music\Desktop.ini","+S+H")
Else
If FileExists($_userdata&"\Desktop.ini") Then
FileSetAttrib($_userdata&"\Desktop.ini","-R-S-H")
IniDelete ($_userdata&"\Desktop.ini","")
FileWrite($_userdata&"\Desktop.ini","[.ShellClassInfo]"&@crlf&"IconFile=%SystemRoot%\system32\SHELL32.dll"&@crlf&"IconIndex=80"&@crlf&"LocalizedResourceName=@shell32.dll,-3838")
FileSetAttrib($_userdata&"\Desktop.ini","+S+H")
Else
FileWrite($_userdata&"\Desktop.ini","[.ShellClassInfo]"&@crlf&"IconFile=%SystemRoot%\system32\SHELL32.dll"&@crlf&"IconIndex=80"&@crlf&"LocalizedResourceName=@shell32.dll,-3838")
FileSetAttrib($_userdata&"\Desktop.ini","+S+H")
EndIf
EndIf
EndFunc
Func _write_hkcc($_userdata) ;修改当前用户文件夹路径到D:\userdata\下面
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop","REG_SZ",$_userdata&"\桌面")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Favorites","REG_EXPAND_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Personal","REG_SZ",$_userdata&"\My Documents")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","My Pictures","REG_SZ",$_userdata&"\My Documents\My Pictures")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","My Music","REG_SZ",$_userdata&"\My Documents\My Music")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\New","Favorites","REG_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\New","My Video","REG_SZ",$_userdata&"\My Documents")
; ————————————————————————————————————————————
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Desktop","REG_SZ",$_userdata&"\桌面")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Favorites","REG_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","REG_SZ",$_userdata&"\My Documents")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Pictures","REG_SZ",$_userdata&"\My Documents\My Pictures")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Music","REG_SZ",$_userdata&"\My Documents\My Music")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Favorites","REG_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Video","REG_SZ",$_userdata&"\My Documents")
; ********************************************
EndFunc
Func _write_hku($_userdata) ;修改以后创建的用户文件夹路径到D:\userdata\下面
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop","REG_SZ",$_userdata&"\桌面")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Favorites","REG_EXPAND_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Personal","REG_SZ",$_userdata&"\My Documents")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","My Pictures","REG_SZ",$_userdata&"\My Documents\My Pictures")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","My Music","REG_SZ",$_userdata&"\My Documents\My Music")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\New","Favorites","REG_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\New","My Video","REG_SZ",$_userdata&"\My Documents")
; ————————————————————————————————————————————
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Desktop","REG_SZ",$_userdata&"\桌面")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Favorites","REG_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","REG_SZ",$_userdata&"\My Documents")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Pictures","REG_SZ",$_userdata&"\My Documents\My Pictures")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Music","REG_SZ",$_userdata&"\My Documents\My Music")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Favorites","REG_SZ",$_userdata&"\Favorites")
RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","My Video","REG_SZ",$_userdata&"\My Documents")
; ********************************************
EndFunc
Func _write_common($_userdata) ;修改所有共享用户文件夹路径到D:\userdata\下面
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","REG_SZ",$_userdata&"\My Documents")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","CommonMusic","REG_SZ",$_userdata&"\All Users\Documents\My Music")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","CommonVideo","REG_SZ",$_userdata&"\All Users\Documents\My Videos")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","CommonPictures","REG_SZ",$_userdata&"\All Users\Documents\My Pictures")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Common Documents","REG_SZ",$_userdata&"\All Users\Documents")
; ————————————————————————————————————————————
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths",@UserName,"REG_SZ",$_userdata&"\My Documents")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Common Documents","REG_EXPAND_SZ",$_userdata&"\All Users\Documents")
; ********************************************
EndFunc |
|