找回密码
 加入
搜索
查看: 1939|回复: 1

[AU3基础] 系统文件夹修改路径

  [复制链接]
发表于 2011-9-22 00:54:39 | 显示全部楼层 |阅读模式
本帖最后由 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
发表于 2011-9-22 09:17:25 | 显示全部楼层
标题违规!锁帖!请修改标题后PM管理人员打开主题!谢谢合作!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 10:26 , Processed in 0.074611 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表