系统桌面白屏(Active故障)修复批处理

用户桌面经常会出现壁纸无法显示,ActiveDesktop桌面损坏之类的故障,当时从前人心得里学到的方法就是登入管理员,然后删除用户配置目录(%userprofile%),然后重新登入之后用户桌面就能正常了.
如此确实能修复这白屏故障桌面,但是用户的所有事设置均被重置,加大了维护工作量,这不是做维护愿意看到的,于是左查右查,我终于找到了症结所在!

原来,加入AD后,域用户的桌面都是网域服务器来配置的,而Active桌面就是从网域获取的一个叫做Desktop.htt的配置文件来控制的,每次用户环境的刷新,都会从AD服务器重新获取新的配置文件,当出现故障的时候(没深究,大概就是网域通讯之类的故障),Desktop.htt文件内容将会改变,都是无法连接之类的描述,从而造成了Active桌面故障,一片惨白!
于是,最开始就有了手动解决的办法,从正常用户环境得到正常的文件,将里面的分辨率修改成目标电脑分辨率并拷贝这个文件去覆盖损坏的desktop.htt,然后立刻设置为只读属性(否则一刷新就被损坏文件重新覆盖,从网域抓取失败时,生成的错误文件)。

问题到这里,至少有了解决办法,但是还是挺麻烦,还是不是作为超级懒人的我所要的答案,于是我就动手写个批处理好了,于是就有了下面这个代码:

@echo off
color 2f
mode con cols=39 lines=8
title ※白屏修复工具※ Ver 2.2 By Mars.Ge
rem 获取屏幕分辨率,以便重写desktop.htt.
echo Set oIE = CreateObject("htmlfile"):With oIE.parentWindow.screen:wsh.echo .width,"*",.height:End With>"%TMP%\vbs.tmp"
for /f "delims=* tokens=1,2"? %%i in ('cscript.exe //e:vbscript //nologo %TMP%\vbs.tmp') do (
if /i "%%i" gtr "0" set X=%%i & Set Y=%%j
)
rem 生成Desktop.htt文件
echo ^ >"%tmp%\Desktop.htt"
echo ^ >>"%tmp%\Desktop.htt"
echo ^ >>"%tmp%\Desktop.htt"
echo ^
系统桌面白屏(Active故障)修复批处理-第1张-讯沃blog(讯沃blog)
>>"%tmp%\Desktop.htt" echo ^ >>"%tmp%\Desktop.htt" echo ^ >>"%tmp%\Desktop.htt" echo ^
>>"%tmp%\Desktop.htt" rem 对已损坏的desktop.htt去属性处理 echo y|cacls /t /c /g "%userprofile%\Application Data\Microsoft\Internet Explorer\Desktop.htt" everyone:f attrib -r -h -S "%userprofile%\Application Data\Microsoft\Internet Explorer\Desktop.htt" >nul echo= rem 以新生成的desktop.htt覆盖 copy /y "%tmp%\Desktop.htt" "%userprofile%\Application Data\Microsoft\Internet Explorer\" attrib +r +h +s "%userprofile%\Application Data\Microsoft\Internet Explorer\Desktop.htt" >nul rem 判断桌面壁紙是否存在 if not exist "C:\windows\web\wallpaper\youjbg.jpg"? ( goto Repair2 ) else ( Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters echo= echo 桌面白屏故障修复成功! echo= echo 任意键退出... pause>NUL exit ) :Repair2 title ※修复桌面故障[桌面及壁紙]※ echo= copy /y youjpg.jpg C:\windows\web\wallpaper\pg.jpg 1>nul 2>NUL Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters echo 桌面白屏及壁紙故障修复成功! echo= echo 任意键退出... pause>nul goto exit @echo off color 2f mode con cols=39 lines=8 title ※白屏修复工具※ Ver 2.2 By Mars.Ge rem 获取屏幕分辨率,以便重写desktop.htt. echo Set oIE = CreateObject("htmlfile"):With oIE.parentWindow.screen:wsh.echo .width,"*",.height:End With>"%TMP%\vbs.tmp" for /f "delims=* tokens=1,2"? %%i in ('cscript.exe //e:vbscript //nologo %TMP%\vbs.tmp') do ( if /i "%%i" gtr "0" set X=%%i & Set Y=%%j ) rem 生成Desktop.htt文件 echo ^ >"%tmp%\Desktop.htt" echo ^ >>"%tmp%\Desktop.htt" echo ^ >>"%tmp%\Desktop.htt" echo ^
系统桌面白屏(Active故障)修复批处理-第1张-讯沃blog(讯沃blog)
>>"%tmp%\Desktop.htt" echo ^ >>"%tmp%\Desktop.htt" echo ^ >>"%tmp%\Desktop.htt" echo ^
>>"%tmp%\Desktop.htt" rem 对已损坏的desktop.htt去属性处理 echo y|cacls /t /c /g "%userprofile%\Application Data\Microsoft\Internet Explorer\Desktop.htt" everyone:f attrib -r -h -S "%userprofile%\Application Data\Microsoft\Internet Explorer\Desktop.htt" >nul echo= rem 以新生成的desktop.htt覆盖 copy /y "%tmp%\Desktop.htt" "%userprofile%\Application Data\Microsoft\Internet Explorer\" attrib +r +h +s "%userprofile%\Application Data\Microsoft\Internet Explorer\Desktop.htt" >nul rem 判断桌面壁紙是否存在 if not exist "C:\windows\web\wallpaper\bg.jpg"? ( goto Repair2 ) else ( Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters echo= echo 桌面白屏故障修复成功! echo= echo 任意键退出... pause>NUL exit ) :Repair2 title ※修复桌面故障[桌面及壁紙]※ echo= copy /y youjpg.jpg C:\windows\web\wallpaper\youjpg.jpg 1>nul 2>NUL Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters Rundll32.exe USER32.DLL,UpdatePerUserSystemParameters echo 桌面白屏及壁紙故障修复成功! echo= echo 任意键退出... pause>nul goto exit

1 2

© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏
分享
评论 抢沙发

请登录后发表评论