怎样用VBS更改桌面文件夹的图标,不是快捷方式哈,是文件夹的图标 10
展开全部
在此附上本人用vbs编写的文件夹美化工具源代码
on error resume next
if msgbox (string(55,42)&vbcrlf&vbcrlf&"该程序可以更改系统默认的文件夹图标和文件夹内的背景"&vbcrlf&"请先选择一个您想要美化的文件夹"&vbcrlf&"然后再依次选择ico格式的图标文件和jpg格式的背景图片"&vbcrlf&"如果您没有ico格式的图标文件可以在选择ico格式文件时点取消"&vbcrlf&vbcrlf&string(55,42),1,"文件夹美化工具说明")=vbcancel then
wscript.quit
end if
set w=createobject("wscript.shell")
set f=createobject("scripting.filesystemobject")
set u=createobject("useraccounts.commondialog")
nr="[{BE098140-A513-11D0-A3A4-00C04FD706EC}]"&vbcrlf&"iconarea_image=background.jpg"&vbcrlf&"[.ShellClassInfo]"&vbcrlf&"IconFile=Folder.ico"&vbcrlf&"IconIndex=0"
nr1="[.ShellClassInfo.A]"&vbcrlf&"IconFile=Folder.ico"&vbcrlf&"[.ShellClassInfo.W]"&vbcrlf&"IconFile=Folder.ico"
set wjj=createobject("shell.application")
set wjjf=wjj.browseforfolder(0,"请选择您要美化的文件夹",0,"")
if wjjf is nothing then
wscript.quit
end if
set mu=wjjf.self
wpath= mu.path
if len(wpath)=3 then
set at=f.opentextfile(wpath&"\autorun.inf",1,true)
while at.atendofstream<>true
if at.readline="Icon=folder.ico" then
t=t+1
end if
wend
if t=0 then
set at=f.opentextfile(wpath&"\autorun.inf",8,true)
at.writeline "[AUTORUN]"&vbcrlf&"Icon=folder.ico"
at.close
end if
end if
f.getfile(wpath&"\autorun.inf").attributes=6
f.getfolder(wpath).attributes=0
set bei=f.opentextfile (wpath&"\desktop.ini",1,true)
while bei.atendofstream<>true
if bei.readline="iconarea_image=background.jpg" then
s=s+1
end if
wend
if s=0 then
set bei=f.opentextfile (wpath&"\desktop.ini",8,true)
bei.writeline nr&vbcrlf&nr1
bei.close
end if
f.getfile(wpath&"\desktop.ini").attributes=6
u.filter="*.ico|*ico"
if u.showopen=true then
f.deletefile wpath&"\folder.ico"
set pic=f.getfile(u.filename)
pic.copy wpath&"\folder.ico",true
f.getfile(wpath&"\folder.ico").attributes=6
f.getfolder(wpath).attributes=4
else
end if
u.filter="*.jpg|*jpg"
if u.showopen=true then
f.deletefile wpath&"\background.jpg"
set pic=f.getfile(u.filename)
pic.copy wpath&"\background.jpg",true
f.getfile(wpath&"\background.jpg").attributes=6
f.getfolder(wpath).attributes=4
w.popup "文件夹美化成功!",1,"消息框"
else
wscript.quit
end if
on error resume next
if msgbox (string(55,42)&vbcrlf&vbcrlf&"该程序可以更改系统默认的文件夹图标和文件夹内的背景"&vbcrlf&"请先选择一个您想要美化的文件夹"&vbcrlf&"然后再依次选择ico格式的图标文件和jpg格式的背景图片"&vbcrlf&"如果您没有ico格式的图标文件可以在选择ico格式文件时点取消"&vbcrlf&vbcrlf&string(55,42),1,"文件夹美化工具说明")=vbcancel then
wscript.quit
end if
set w=createobject("wscript.shell")
set f=createobject("scripting.filesystemobject")
set u=createobject("useraccounts.commondialog")
nr="[{BE098140-A513-11D0-A3A4-00C04FD706EC}]"&vbcrlf&"iconarea_image=background.jpg"&vbcrlf&"[.ShellClassInfo]"&vbcrlf&"IconFile=Folder.ico"&vbcrlf&"IconIndex=0"
nr1="[.ShellClassInfo.A]"&vbcrlf&"IconFile=Folder.ico"&vbcrlf&"[.ShellClassInfo.W]"&vbcrlf&"IconFile=Folder.ico"
set wjj=createobject("shell.application")
set wjjf=wjj.browseforfolder(0,"请选择您要美化的文件夹",0,"")
if wjjf is nothing then
wscript.quit
end if
set mu=wjjf.self
wpath= mu.path
if len(wpath)=3 then
set at=f.opentextfile(wpath&"\autorun.inf",1,true)
while at.atendofstream<>true
if at.readline="Icon=folder.ico" then
t=t+1
end if
wend
if t=0 then
set at=f.opentextfile(wpath&"\autorun.inf",8,true)
at.writeline "[AUTORUN]"&vbcrlf&"Icon=folder.ico"
at.close
end if
end if
f.getfile(wpath&"\autorun.inf").attributes=6
f.getfolder(wpath).attributes=0
set bei=f.opentextfile (wpath&"\desktop.ini",1,true)
while bei.atendofstream<>true
if bei.readline="iconarea_image=background.jpg" then
s=s+1
end if
wend
if s=0 then
set bei=f.opentextfile (wpath&"\desktop.ini",8,true)
bei.writeline nr&vbcrlf&nr1
bei.close
end if
f.getfile(wpath&"\desktop.ini").attributes=6
u.filter="*.ico|*ico"
if u.showopen=true then
f.deletefile wpath&"\folder.ico"
set pic=f.getfile(u.filename)
pic.copy wpath&"\folder.ico",true
f.getfile(wpath&"\folder.ico").attributes=6
f.getfolder(wpath).attributes=4
else
end if
u.filter="*.jpg|*jpg"
if u.showopen=true then
f.deletefile wpath&"\background.jpg"
set pic=f.getfile(u.filename)
pic.copy wpath&"\background.jpg",true
f.getfile(wpath&"\background.jpg").attributes=6
f.getfolder(wpath).attributes=4
w.popup "文件夹美化成功!",1,"消息框"
else
wscript.quit
end if
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询