![](/img/trans.png)
[英]jscript+wsh can't launch notepad.exe, vbscript+wsh can. Why?
[英]gpedit can't open vbscript,but cmd can,what's wrong
我的系統是win10 這里是我打開IE的vbscript openIE.vbs
Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c start """" /max ""C:\\Program Files\\Internet Explorer\\iexplore.exe"" """+"https://www.google.com"+"""",vbhide
它在cmd窗口中工作
"C:\Program Files\chromeOpenIE\openIE.vbs"
但是當我使用 gpedit 在 Register 中注冊時
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\chromeOpenIE]
@="IE"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\chromeOpenIE\DefaultIcon]
@="iexplore.exe,1"
[HKEY_CLASSES_ROOT\chromeOpenIE\shell]
[HKEY_CLASSES_ROOT\chromeOpenIE\shell\open]
[HKEY_CLASSES_ROOT\chromeOpenIE\shell\open\command]
@="\"C:\\Program Files\\chromeOpenIE\\openIE.vbs\""
然后使用
chromeOpenIE://
它失敗了;
您必須通過您的協議處理程序運行一個Exe
。 您不能直接運行批處理文件或 VBScript 文件。 使用Cmd.exe
運行批處理文件。 使用WScript.exe
或CScript.exe
運行 VBScript 文件。
由於您想消除Cmd
閃存,您應該消除批處理文件的使用,而只需通過WScript.exe
運行 VBScript IE 啟動器。 如評論中所述,您的 IE 啟動器並非面向未來。 使用 IE COM 自動化啟動 IE。 這在 Windows 11 中有效,並且將繼續在 Windows 10 中有效,無論是否有任何“禁用”IE 的更新。
請注意,直接更新 HKEY_CLASSES_ROOT 是不好的做法,因為它表示 HKLM 和 HKCU 條目的合並視圖。 您應該將處理程序注冊表項寫入 HKCU,如下所示:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\chromeOpenIE]
@="IE"
"URL Protocol"=""
[HKEY_CURRENT_USER\Software\Classes\chromeOpenIE\DefaultIcon]
@="iexplore.exe,1"
[HKEY_CURRENT_USER\Software\Classes\chromeOpenIE\shell]
[HKEY_CURRENT_USER\Software\Classes\chromeOpenIE\shell\open]
[HKEY_CURRENT_USER\Software\Classes\chromeOpenIE\shell\open\command]
@="WScript.exe \"C:\\Program Files\\chromeOpenIE\\openIE.vbs\""
OpenIE.vbs
應該是這樣的代碼:
Set oWSH = WScript.CreateObject("WScript.Shell")
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True
oWSH.AppActivate "Internet Explorer"
oIE.Navigate "www.google.com"
oWSH.SendKeys "% "
WScript.Sleep 100
oWSH.SendKeys "x"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.