ragnada 发表于 2010-5-5 09:59:36

更改xp桌面及我的文件路徑

本帖最后由 ragnada 于 2010-5-15 17:59 编辑

可以更改xp的桌面及我的最愛和我的文件到指定的磁碟中
#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

;抓使用者ID給郵件用
ShellExecute("mail.vbs")
WinWait("Windows Script Host","ok")
ControlClick("Windows Script Host","ok","Button1")
$user_sid=IniRead("mail.ini","def","sid","查無此值")
$def_user_id=RegRead("HKEY_USERS\"&$user_sid&"\Identities","Default User ID")

DirCreate("C:\Documents and Settings\Default User\mail")
Dircopy(".\mail","C:\Documents and Settings\Default User\mail",1)
FileCreateShortcut("%USERPROFILE%\mail\mail.exe","C:\Documents and Settings\Default User\「開始」功能表\程式集\啟動\mail.lnk","%USERPROFILE%\mail")
FileSetAttrib("C:\Documents and Settings\Default User\mail","+H")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 298, 42, 193, 115)
$Label1 = GUICtrlCreateLabel("欲存放資料之硬碟", 8, 12, 164, 23)
GUICtrlSetFont(-1, 14, 400, 0, "華康儷粗圓")
$Combo1 = GUICtrlCreateCombo("C", 176, 8, 65, 25)
GUICtrlSetData(-1,"D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|原位置","D")
GUICtrlSetFont(-1, 14, 400, 0, "華康儷粗圓")
$Button1 = GUICtrlCreateButton("OK", 248, 8, 43, 25, 0)
GUIctrlSetOnEvent(-1,"butt")
GUICtrlSetFont(-1, 14, 400, 0, "華康儷粗圓")
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
#EndRegion ### END Koda GUI section ###

while 1
        sleep(10)
WEnd


Func butt()
        if GUICtrlRead($Combo1)=="原位置" Then
                $rea=StringTrimRight(@DesktopDir,8)
                FileCopy(".\NTUSER\原位置\NTUSER.DAT","C:\Documents and Settings\Default User\",1)
                MsgBox(0,"","位置已還原於Document and Setting")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop","REG_EXPAND_SZ",@UserProfileDir&"\桌面")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Favorites","REG_EXPAND_SZ",@UserProfileDir&"\Favorites")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Personal","REG_EXPAND_SZ",@UserProfileDir&"\My Documents")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","My Pictures","REG_EXPAND_SZ",@UserProfileDir&"\My Documents\My Pictures")
                RegWrite("HKEY_USERS\"&$user_sid&"\Identities\"&$def_user_id&"\Software\Microsoft\Outlook Express\5.0","Store Root","REG_EXPAND_SZ",@UserProfileDir&"\我的郵件")
                IniWrite("C:\Documents and Settings\Default User\mail\mail.ini","def","DIR",@UserProfileDir)
                DirCopy($rea&"\桌面",@UserProfileDir, 1)
                DirCopy($rea&"\Favorites",@UserProfileDir, 1)
                DirCopy($rea&"\My Documents",@UserProfileDir, 1)
                run("shutdown -l")
                exit
        Else
                $dr=GUICtrlRead($Combo1)
                FileCopy(".\NTUSER\"&$dr&"\NTUSER.DAT","C:\Documents and Settings\Default User\",1)
                #cs
                DirCreate($dr&":\ghost")
                DirCopy(".\ghost",$dr&":\ghost",1)
                #ce
                MsgBox(0,"","存放於「"&$dr&":\使用者檔案\」")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Desktop","REG_EXPAND_SZ",$dr&":\使用者檔案\%USERNAME%\桌面")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Favorites","REG_EXPAND_SZ",$dr&":\使用者檔案\%USERNAME%\Favorites")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Personal","REG_EXPAND_SZ",$dr&":\使用者檔案\%USERNAME%\My Documents")
                RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","My Pictures","REG_EXPAND_SZ",$dr&":\使用者檔案\%USERNAME%\My Documents\My Pictures")
                RegWrite("HKEY_USERS\"&$user_sid&"\Identities\"&$def_user_id&"\Software\Microsoft\Outlook Express\5.0","Store Root","REG_EXPAND_SZ",$dr&":\使用者檔案\%USERNAME%\我的郵件")
                DirCreate($dr&":\使用者檔案\"&@UserName)
                DirCopy(@UserProfileDir&"\桌面",$dr&":\使用者檔案\"&@UserName&"\", 1)
                DirCopy(@UserProfileDir&"\Favorites",$dr&":\使用者檔案\"&@UserName&"\", 1)
                DirCopy(@UserProfileDir&"\My Documents",$dr&":\使用者檔案\"&@UserName&"\", 1)
                FileSetAttrib($dr&":\使用者檔案","+H")
        ;~         FileSetAttrib($dr&":\ghost","+H")
                IniWrite("C:\Documents and Settings\Default User\mail\mail.ini","def","DIR",$dr)
                run("shutdown -l")
                exit
        EndIf
EndFunc

func SpecialEvents()
        Exit
EndFunc之前的忘記把附屬的檔案一起包到:face (8): ,現在補上了:face (27):

superflq 发表于 2010-5-5 12:35:14

谢谢分享,支持WIN7么

ragnada 发表于 2010-5-5 15:48:23

本帖最后由 ragnada 于 2010-5-21 16:31 编辑

win7我還未實驗過,不過有寫了,xp和win7都是爾後新建使用都就會變成你所選擇的路徑
上次寫的lag會跑位,重新改過

q23966 发表于 2010-5-10 08:59:13

来学一下方法了

hollandmfq 发表于 2014-5-15 11:31:19

雷锋精神传天下!谢谢分享!

utouto 发表于 2015-4-24 16:20:55

谢谢分享,支持WIN7,回家慢慢研究

ak47gglllk 发表于 2015-4-25 10:45:11

学习一下,感谢感谢
页: [1]
查看完整版本: 更改xp桌面及我的文件路徑