天天看点

【技术贴】ActiveX 部件不能创建对象 Wscript.Shell,右键打开所在目录的批处理ba

开始 -- 运行 -- 输入regsvr32 %windir%\system32\WSHom.Ocx 回车

开始 -- 运行 -- 输入regsvr32 /u scrrun.dll 回车

以上两步即可解决此问题。没有为什么,微软说的。

  同时奉献两个最好用的右键打开所在目录的批处理文件,提供卸载。

   --------------------------------------------安装.bat--------------------------

@echo off

color 0A

title 开启右键打开快捷方式所在目录成功......

mode con cols=40 lines=10

echo set args = WScript.Arguments>>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo linkname = args(0)>>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo. >>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo set wshshell = CreateObject("WScript.Shell")>>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo set scut = wshshell.CreateShortcut(linkname)>>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo set fs = CreateObject("Scripting.FileSystemObject")>>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo folder = """" ^& fs.GetParentFolderName(scut.TargetPath) ^& """">>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo wshshell.Run(folder)>>C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

if exist "tmp.reg" del "tmp.reg"

echo Windows Registry Editor Version 5.00>>tmp.reg

echo. >>tmp.reg

echo [HKEY_CLASSES_ROOT\lnkfile\shell]>>tmp.reg

echo [HKEY_CLASSES_ROOT\lnkfile\shell\打开所在目录]>>tmp.reg

echo [HKEY_CLASSES_ROOT\lnkfile\shell\打开所在目录\command]>>tmp.reg

echo @="wscript.exe \"C:\\windows\\system32\\open_shrtct_parent_folder.vbs\" \"%%%L\"">>tmp.reg

echo. >>tmp.reg 

regedit /s "tmp.reg" >nul 2>nul

del "tmp.reg"

echo.

echo.      【开启成功,任意键退出】 

pause>nul 

exit

-----你懂得怎么用的。(以上内容复制进txt并重命名为xx.bat双击即可。)------------- 

--------------------------------------------- 卸载.bat--------------------------------------

title 关闭右键打开快捷方式所在目录成功......

reg delete HKEY_CLASSES_ROOT\lnkfile\shell /f

del C:\WINDOWS\system32\open_shrtct_parent_folder.vbs

echo.       【按任意键退出】 

---------------------------------------你懂得怎么用的。------------------------------------------

之所以出现这个帖子就是因为这个错误的出现,使得这两个bat文件操作后,不能打开所在目录,所以运行了开头的那两个步骤后,一切完美。