天天看點

【技術貼】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檔案操作後,不能打開所在目錄,是以運作了開頭的那兩個步驟後,一切完美。

繼續閱讀