Board logo

标题: 重启“资源管理器"之→VBS版 [打印本页]

作者: baomaboy     时间: 2007-3-17 12:42    标题: 重启“资源管理器"之→VBS版

应chengbiner要求而发,其实就两句话: 判断是Nt还是9x系统分别用: ntsd -c q -pn Explorer.exe RUNDLL32 SHELL32.DLL,SHExitWindowsEx -1 多用于修改注册表之后及时生效, 为了方便随时操作放在了文件和文件夹右键菜单中。
附件 1: Restare_Explorer.rar (2007-3-17 12:42, 5.12 K,下载次数: 69)
附件 2: 1.GIF (2007-3-17 12:42, 5.38 K,下载次数: 3)



作者: lxmxn     时间: 2007-3-17 13:23
  第2个命令,我在命令行支持出错了,说是丢失条目“SHExitWindowsEx”,怎么回事?

作者: baomaboy     时间: 2007-3-17 13:27
Originally posted by lxmxn at 2007-3-17 13:23:   第2个命令,我在命令行支持出错了,说是丢失条目“SHExitWindowsEx”,怎么回事?
第2个命令是用于WinMe的,同样内核估计98也可以用,xp中已取消了, 之所以写此命令是因为Win9x系列不支持第1个命令ntsd (没测试过,应该是吧) [ Last edited by baomaboy on 2007-3-17 at 01:28 PM ]

作者: lxmxn     时间: 2007-3-17 13:32
  哦,原来如此。XP下有没有类似的命令呢?

作者: baomaboy     时间: 2007-3-17 13:35
没查到过相关的类似命令,下面这个xp下也可以 For Each Process in GetObject("winmgmts:"). _ ExecQuery ("select * from Win32_Process where name='explorer.exe'") Process.terminate(0) Next

作者: lxmxn     时间: 2007-3-17 13:46
  嗯,这个VBS的结束进程的不错。下面的命令都可以达到结束explorer.exe进程的效果: 1、Wmic process where "name='explorer.exe'" call terminate 2、Taskkill /f /im explorer.exe 3、Ntsk -c q -pn explorer.exe 4、Stop-Process -name explorer(Windows PowerShell下使用)

作者: baomaboy     时间: 2007-3-17 14:04
Originally posted by lxmxn at 2007-3-17 13:46:   嗯,这个VBS的结束进程的不错。下面的命令都可以达到结束explorer.exe进程的效果: 1、Wmic process where "name='explorer.exe'" call ...
好多啊,收藏备用了。 兄有遇到过结束后不能重建explorer.exe的情况吗?只留个空桌面,还得手动任务管理器运行,不知是否我的系统不稳定的原因还是其他? 由于不知原因所在所以没有正统的解决方法,只能在代码中加入结束explorer.exe进程3秒后查找explorer.exe进程有则退出,无则重建。 最初的代码没加延时就重建explorer.exe,后来不知是系统稳定了还是其他原因每次都会多开个explorer.exe窗口出来 ^_^ [ Last edited by baomaboy on 2007-3-17 at 02:15 PM ]

作者: baomaboy     时间: 2007-4-13 14:05
Dim WshSHell,FSO On Error Resume Next Set WshSHell = WScript.CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") Set WinVer = WshSHell.Environment("Process") Set Args = WScript.Arguments CloseTime = 5 FileName = WScript.ScriptName FileFullName = WScript.ScriptFullName FilePath = FSO.GetParentFolderName(FileFullName) InsPath = FSO.GetSpecialFolder(1) InsFullName = FSO.BuildPath(InsPath ,FileName) LnkPathNT = WshSHell.SpecialFolders(2) LnkPath9X = WshSHell.SpecialFolders(14) LnkPathAll = WshSHell.SpecialFolders("StartMenu") OtherFileName="PathCopyEx.dll" OtherFilePath=FSO.GetSpecialFolder(1) TemFileName = "PathCopyEx.reg" TemFilePath = FSO.GetSpecialFolder(1) Copyright="玲珑科技" QQ="QQ:25926183" Email="Email:fty1995@163.com" InsTitle="重新启动资源管理器" InsAnswer="重新启动资源管理器" RegPath1="HKEY_CLASSES_ROOT\*\shell\Restare_Explorer\" RegValue1="重新启动资源管理器" RegForm1="REG_SZ" RegPath2="HKEY_CLASSES_ROOT\*\shell\Restare_Explorer\command\" RegValue2="wscript.exe "&InsFullName RegForm2="REG_SZ" RegPath3="HKEY_CLASSES_ROOT\Directory\shell\Restare_Explorer\" RegValue3="重新启动资源管理器" RegForm3="REG_SZ" RegPath4="HKEY_CLASSES_ROOT\Directory\shell\Restare_Explorer\command\" RegValue4="wscript.exe "&InsFullName RegForm4="REG_SZ" RegPath9="HKEY_CLASSES_ROOT\Drive\shell\" RegPath10="HKEY_CLASSES_ROOT\Directory\shell\" RegValue13="open" WshSHell.RegWrite RegPath9,RegValue13,RegForm1 WshSHell.RegWrite RegPath10,RegValue13,RegForm1 IF FileFullName <> InsFullName then intAnswer = MsgBox("【是】将“"+ InsAnswer +"”加入到右键菜单,"&Chr(10)&Chr(10)&"【否】将“"+ InsAnswer +"”从右键菜单删除。 ", vbQuestion + vbYesNoCancel, "安装 - "+ InsTitle +" - "+ Copyright) If intAnswer = vbYes Then WshSHell.RegWrite RegPath1,RegValue1,RegForm1 WshSHell.RegWrite RegPath2,RegValue2,RegForm1 WshSHell.RegWrite RegPath3,RegValue3,RegForm3 WshSHell.RegWrite RegPath4,RegValue4,RegForm4 FSO.GetFile(FileFullName).Copy(InsFullName) WshSHell.popup _ "添加脚本文件:"+chr(10)+InsFullName+chr(10)+chr(10)+ _ "添加注册表项:"+chr(10)+chr(34)+ RegPath1 +chr(34)+chr(10)+chr(34)+ RegPath3 +chr(34)+chr(10)+ _ chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _ chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _ , CloseTime, "安装成功 - "+ InsTitle +" - "+ Copyright, 0 + 64 end if If intAnswer = vbNo Then WshSHell.RegDelete RegPath4 WshSHell.RegDelete RegPath3 WshSHell.RegDelete RegPath2 WshSHell.RegDelete RegPath1 FSO.DeleteFile InsFullName WshSHell.popup _ "删除脚本文件:"+chr(10)+InsFullName+chr(10)+chr(10)+ _ "删除注册表项:"+chr(10)+chr(34)+ RegPath3 +chr(34)+chr(10)+chr(34)+ RegPath1 +chr(34)+chr(10)+ _ chr(10) & CloseTime & " 秒钟后本窗口将自动关闭!" +chr(10)+chr(10)+ _ chr(10) & "Copyright(C) " + Copyright +" " & QQ &" " + Email _ , CloseTime, "卸载成功 - "+ InsTitle +" - "+ Copyright, 0 + 64 End If If intAnswer = vbCancel Then end if ELSE If WinVer("OS") <> "Windows_NT" Then WshSHell.Run ("RUNDLL32 SHELL32.DLL,SHExitWindowsEx -1"), vbHide else For Each Process in GetObject("winmgmts:"). _ ExecQuery ("select * from Win32_Process where name='explorer.exe'") Process.terminate(0) Next WScript.Sleep 3000 for each ps in getobject _ ("winmgmts:\\.\root\cimv2:win32_process").instances_ if LCase(ps.name)="explorer.exe" then Set WshSHell = Nothing Set FSO = Nothing Set Args = Nothing WScript.Quit(0) exit for end if next WshSHell.Run ("explorer.exe") end if End IF Set WshSHell = Nothing Set FSO = Nothing Set Args = Nothing WScript.Quit(0)
  [ Last edited by baomaboy on 2008-3-25 at 01:02 AM ]

作者: eech     时间: 2008-7-21 17:57
如果能回到原来的目录,且在桌面空白右键调用就完美了

作者: kidzgy     时间: 2008-7-23 22:04
Originally posted by baomaboy at 2007-3-17 02:04 PM: 好多啊,收藏备用了。 兄有遇到过结束后不能重建explorer.exe的情况吗?只留个空桌面,还得手动任务管理器运行,不知是否我的系统不稳定的原因 ...
我也有遇到过,只不过是在BAT下,自我从版主那取得VBS启动explorer后,就不会出现那问题了。 如果bat里那start explorer.exe 确实会存在不稳定因素,应该是CMD本身的问题。 就算我在下面加了很多条start explorer.exe 有些时候也会运行不上。 我想用vbs比较稳定吧。到现在为止,还没有出现过那不稳定的问题哦 重启explorer.exe的代码是: 放在bat里的 只有两行 @taskkill /im explorer.exe /f >nul @mshta VBScript:CreateObject("WScript.Shell").Run("explorer.exe")(window.close)

作者: chengbiner     时间: 2008-7-24 03:40
感谢baomaboy兄,好久没有来了,没有想到还能看到我的名字,再次感谢baomaboy兄