2008-11-20 19 views
0

註冊表項,我寫了一個腳本來自動生成過程中一點點。RegDelete不能刪除基於在<a href="http://www.tweakguides.com/VA_4.html" rel="nofollow noreferrer">http://www.tweakguides.com/VA_4.html</a>以防止從Windows Vista中的Windows資源管理器「智能化」重新排列列格式的建議在WSH 5.7

Dim WshShell 
Set WshShell = WScript.CreateObject("WScript.Shell") 


'Remove the "filthy" reg keys first. 
regKey = "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\BagMRU\" 


WScript.Echo "Deleting " & regKey & VbCrLf 
WshShell.RegDelete regKey 

regKey = "HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\" 

WScript.Echo "Deleting " & regKey & VbCrLf 
WshShell.RegDelete regKey 


'Then recreate a clean Bags key, with sub-keys and FolderType value. 
regKey = "HKCU\Software\Classes\Local Settings\Software\Microsoft\ Windows\Shell\Bags\AllFolders\Shell\FolderType" 

WScript.Echo "Creating " & regKey & " as 'NotSpecified' REG_SZ " & VbCrLf 
WshShell.RegWrite regKey, "NotSpecified", "REG_SZ" 

WScript.Echo "Now define the columns of your preference in Windows Explorer," & VbCrLf 
WScript.Echo "and click the Apply to Folders button in Folder Options." & VbCrLf 

但它拒絕刪除註冊表項

E:\archive\settings\Windows Vista Explorer columns.vbs(9, 1) WshShell.RegDelete: 
Unable to remove registry key "HKCU\Software\Classes\Local Settings\Software\Mi 
crosoft\Windows\Shell\BagMRU\". 

的建議是把尾部的「\」,表示是關鍵,我做到了。有任何想法嗎?

+0

這可能與權限去做,你以管理員身份運行,並通過用戶編輯這些鍵/組? – 2008-11-20 02:51:21

+0

是的,我是管理員,是的,我禁用UAC所有;-) – icelava 2008-11-20 05:09:21

回答

1

禁用UAC在Windows Vista中,那麼這個腳本將只是正常工作。

2

你的註冊表設置,是否有子項?我認爲你必須先刪除這些密鑰才能刪除密鑰。

1

打破它dooown:)

Const HKCR=&H80000000:Const HKCU=&H80000001:Const HKLM=&H80000002:Const HKU=&H80000003:Const HKCC=&H80000005 

dim pc,o,hive,key,name,value,i 
pc="." 
Set o=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & pc & "\root\default:StdRegProv") 

hive=HKCU 
key="Software\Microsoft\Windows\CurrentVersion\Explorer\Wallpapers\knownfolders\0\windows wallpapers\mergefolders" 
regrid 5 

sub regrid(levels) 
dim a,n,j,base,s 
    a=split(key,"\") 
    n=ubound(a) 
    base="":for i=0 to levels-1:base=base & a(i) & "\":next 
    for i=n to levels step -1 
     s="":for j=levels to i:s=s & a(j) & "\":next 
     o.DeleteKey hive,base & s 
    next 
end sub 

感謝大家的支持,在解放教育

相關問題