Internet explorer 在HTA VBScript中打开IE-不';t支持“;“导航”;

Internet explorer 在HTA VBScript中打开IE-不';t支持“;“导航”;,internet-explorer,vbscript,hta,Internet Explorer,Vbscript,Hta,出于特定的原因,我试图从HTA中打开一个InternetExplorer窗口,并导航到一个特定的URL 经过一些搜索,我找到了下面的解决方案。我成功地打开了Internet Explorer,但我被告知IE对象不支持导航 <!DOCTYPE html> <html lang="en"> <head> <title>Test</title> <hta:application id="oHTA"

出于特定的原因,我试图从HTA中打开一个InternetExplorer窗口,并导航到一个特定的URL

经过一些搜索,我找到了下面的解决方案。我成功地打开了Internet Explorer,但我被告知IE对象不支持导航

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test</title>

    <hta:application
        id="oHTA"
        applicationname="Test"
        application="yes"
        icon=""
    >
    </hta:application>

    <script language="VBScript">
        Sub Sleep(seconds)
            CreateObject("WScript.Shell").Run "%COMSPEC% /c ping 127.0.0.1 -n " & seconds+1, 0, True
        End Sub

        Function openGoogle()

            Set webBrowser = CreateObject("InternetExplorer.Application")
            webBrowser.Visible = True
            webBrowser.Navigate = "https://google.co.uk/"

            Do While webBrowser.ReadyState <> 4 Or webBrowser.Busy
                Sleep 5
            Loop

        End Function

        openGoogle()

    </script>

</head>

<body>
    <h1>Test</h1>
</body>

</html>

试验
亚睡眠(秒)
CreateObject(“WScript.Shell”)。运行“%COMSPEC%/c ping 127.0.0.1-n”&秒+1,0,True
端接头
函数openGoogle()
设置webBrowser=CreateObject(“InternetExplorer.Application”)
webBrowser.Visible=True
webBrowser.Navigate=”https://google.co.uk/"
在webBrowser.ReadyState 4或webBrowser.Busy时执行此操作
睡眠5
环
端函数
openGoogle()
试验

您可以查看以下内容:

此外,您还可以从这个旧的HTA(法语版本)中得到启发,它允许您从命令行启动一些命令,因此,您可以打开系统上安装的任何浏览器的任何链接

请尝试一下以下代码:

<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="Ouvrir des liens avec les navigateurs IE,Chrome et Firefox"
BORDER="THIN"
BORDERSTYLE="NORMAL"
ICON="Explorer.exe"
INNERBORDER="NO"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
SCROLL="NO"
SELECTION="NO"
SINGLEINSTANCE="YES"/>
<META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
<title>Ouvrir des liens avec les navigateurs IE,Chrome et Firefox</title>
<SCRIPT LANGUAGE="VBScript">
'******
Option Explicit
 Function Executer(StrCmd,Console)
 Dim ws,MyCmd,Resultat
 Set ws = CreateObject("wscript.Shell")
'La valeur 0 pour cacher la console MS-DOS
 If Console = 0 Then
 MyCmd = "CMD /C " & StrCmd & " "
 Resultat = ws.run(MyCmd,Console,True)
 If Resultat = 0 Then
 'MsgBox "Success"
 Else
 MsgBox "Une erreur inconnue est survenue !",16,"Une erreur inconnue est survenue !"
 End If
 End If
'La valeur 1 pour montrer la console MS-DOS
 If Console = 1 Then
 MyCmd = "CMD /K " & StrCmd & " "
 Resultat = ws.run(MyCmd,Console,False)
 If Resultat = 0 Then
 'MsgBox "Success"
 Else
 MsgBox "Une erreur inconnue est survenue !",16,"Une erreur inconnue est survenue !"
 End If
 End If
 Executer = Resultat
End Function
'******
Sub window_onload()
 CenterWindow 400,320
End Sub
'******
Sub CenterWindow(x,y)
 Dim iLeft,itop
 window.resizeTo x,y
 iLeft = window.screen.availWidth/2 - x/2
 itop = window.screen.availHeight/2 - y/2
 window.moveTo ileft,itop
End Sub
'******
Sub Ip_Publique()
 Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches,ip_public
 Titre = "Adresse Ip Publique !"
 URL = "http://monip.org"
 If OnLine("smtp.gmail.com") = True Then
 Set ie = CreateObject("InternetExplorer.Application")
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 ie.Navigate (URL)
 ie.Visible=False
 DO WHILE ie.busy
 Sleep 100
 Loop
 Data = ie.document.documentElement.innertext
 Set objRegex = new RegExp
 objRegex.Pattern = "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
 objRegex.Global = False
 objRegex.IgnoreCase = True
 Set Matches = objRegex.Execute(Data)
 For Each Match in Matches
 MsgBox "Votre IP Publique est : "& Match.Value,64,Titre
 Next
 ie.Quit
 Set ie = Nothing
 Else
 MsgBox "Vérifier votre connexion internet puis re-executer ce script",48,Titre
 Exit Sub
 End If
End Sub

'******
Sub Sleep(MSecs)'Fonction pour faire une pause car wscript.sleep ne marche pas dans un HTA
 Dim fso,objOutputFile
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
    Dim tempName : tempName = "Sleeper.vbs"
    If Fso.FileExists(tempFolder&"\"&tempName)=False Then
      Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
      objOutputFile.Write "wscript.sleep WScript.Arguments(0)"
      objOutputFile.Close
    End If
    CreateObject("WScript.Shell").Run tempFolder&"\"&tempName &" "& MSecs,1,True
End Sub
'******
Sub SSID_names()
Dim objShell,fso,File,strContents,objRegEx,objMatch,colMatches
 set objShell = CreateObject("WScript.Shell")
 Set fso = CreateObject("Scripting.FileSystemObject")
 If Executer("netsh wlan show all > Wlan.txt",0) = 0 Then
 Set File = fso.OpenTextFile("Wlan.txt",1)
 strContents = File.ReadAll
 Set objRegEx = New RegExp
 objRegEx.IgnoreCase = True
 objRegEx.Global = True
 objRegEx.Multiline = True
 objRegEx.Pattern = """([^""]+)"""
 set colMatches = objRegEx.Execute(strContents)
 For each objMatch in colMatches
 MsgBox "SSID name: " & objMatch.Value,64,"SSID name"
 Next
 End If
End sub
'******
Function OnLine(strHost)
Dim objPing,z,objRetStatus,PingStatus
    Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & strHost & "'")
    z = 0
    Do   
      z = z + 1
      For Each objRetStatus In objPing
      If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <> 0 Then
            PingStatus = False
      Else
            PingStatus = True
      End If     
    Next   
      sleep 200
      If z = 4 Then Exit Do
    Loop until PingStatus = True
    If PingStatus = True Then
      OnLine = True
    Else
      OnLine = False
    End If
End Function
'******
Sub WLAN_Networks()
 If Executer("netsh wlan show profiles > Wlan_tmp.txt & netsh wlan show networks >> Wlan_tmp.txt & netsh wlan show interfaces >> Wlan_tmp.txt & cmd /U /C Type Wlan_tmp.txt > Wlan_Networks.txt",0) = 0 Then
 Call Executer("Start Wlan_Networks.txt & Del Wlan_tmp.txt",0)
 End If
End Sub
</script>
</head>
<p>Une liste de liens :</p>
<ol>
<li><a href="#" onClick="Call Executer('Start iexplore.exe www.google.com',0)">Lien Google avec iexplore.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe http://bbat.forumeiro.com/',0)">Lien BBAT avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start Firefox.exe www.developpez.net',0)">Lien developpez.net avec Firefox.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.yahoo.fr',0)">Lien Yahoo avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.fr',0)">Lien Autoitscript.fr (Français) avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.com',0)">Lien autoitscript.com (Anglais) avec Chrome.exe</a></li>
<li><a href="#" onClick="Call Executer('Start www.sfr.fr',0)">Lien SFR avec votre navigateur par défaut</a></li>
</ol>
<BODY text=white bgcolor="DarkOrange" TOPMARGIN="1" LEFTMARGIN="1">
 <center><button onclick="Call Executer('mode con cols=90 lines=15 & Color 0A & Title Ping sur www.developpez.net by Hackoo & Ping www.developpez.net',1)">Ping sur developpez.net</button>
 <center><button onclick="Call Executer('FindStr /? > HelpFindStrTmp.txt & cmd /U /C Type HelpFindStrTmp.txt > HelpFindStr.txt & start HelpFindStr.txt',0)">Help sur FindStr</button>
 <button onclick="Call Executer('ipconfig /all > configTmp.txt & cmd /U /C Type configTmp.txt > MyIPconfig.txt & start MyIPconfig.txt',0)">IpConfig</button>
 <button onclick="Call Executer('mode con cols=80 lines=50 & Color 9B & Title Hackoo & netstat -a',1)">Netstat</button>
 <button onclick="Call Executer('mode con cols=60 lines=10 & Color 0A & Title Hackoo & arp -a',1)">Arp</button>
 <button onclick="Call Executer('mode con cols=80 lines=30 & Color 9B & Title Tracert vers www.developpez.com by Hackoo & Tracert www.developpez.com',1)">Tracert</button><br>
 <center><button onclick="Call Ip_Publique">IP Publique</button>
 <button onclick="Call SSID_names()">SSID WLAN</button>
  <button onclick="Call WLAN_Networks()">WLAN Network</button>
 </center>
 </center>
</body>
</html> 

浏览器、浏览器和火狐浏览器
'******
选项显式
功能执行器(StrCmd、控制台)
Dim ws、MyCmd、Resultat
设置ws=CreateObject(“wscript.Shell”)
'La valeur 0倾倒缓存器La控制台MS-DOS
如果Console=0,则
MyCmd=“CMD/C”和StrCmd&“
Resultat=ws.run(MyCmd,控制台,True)
如果Resultat=0,则
“MsgBox”成功
其他的
MsgBox“在任何情况下都是错误的!”,16,“在任何情况下都是错误的!”
如果结束
如果结束
“La valeur 1 pour montrer La console MS-DOS
如果Console=1,则
MyCmd=“CMD/K”和StrCmd&“
Resultat=ws.run(MyCmd,Console,False)
如果Resultat=0,则
“MsgBox”成功
其他的
MsgBox“在任何情况下都是错误的!”,16,“在任何情况下都是错误的!”
如果结束
如果结束
Executer=Resultat
端函数
'******
子窗口_onload()
中心窗口400320
端接头
'******
副中心窗口(x,y)
伊托普
window.resizeTo x,y
iLeft=window.screen.availWidth/2-x/2
itop=window.screen.availHeight/2-y/2
window.moveTo ileft,itop
端接头
'******
副Ip_Publique()
尺寸标题、URL、ie、objFSO、数据、输出、objRegex、匹配、匹配、ip_公共
Titre=“地址:Ip Publique!”
URL=”http://monip.org"
如果在线(“smtp.gmail.com”)=True,则
设置ie=CreateObject(“InternetExplorer.Application”)
设置objFSO=CreateObject(“Scripting.FileSystemObject”)
ie.导航(URL)
可见=假
忙着干吧
睡100
环
数据=ie.document.documentElement.innertext
Set objRegex=new RegExp
模式=“\b([0-9]{1,3}\){3}[0-9]{1,3}\b”
objRegex.Global=False
objRegex.IgnoreCase=True
Set Matches=objRegex.Execute(数据)
比赛中的每一场比赛
MsgBox“Votre IP Publique est:&匹配值,64,滴度
下一个
即退出
设置ie=无
其他的
MsgBox“Vérifier votre connexion internet puis re executer ce script”,48,标题
出口接头
如果结束
端接头
'******
子睡眠(MSecs)功能暂停汽车wscript.Sleep ne marche pas dans un HTA
Dim fso,对象输出文件
设置fso=CreateObject(“Scripting.FileSystemObject”)
Dim tempFolder:Set tempFolder=fso.GetSpecialFolder(2)
Dim tempName:tempName=“Sleeper.vbs”
如果Fso.FileExists(tempFolder&“\”&tempName)=False,则
设置objOutputFile=fso.CreateTextFile(tempFolder&“\”&tempName,True)
objOutputFile.Write“wscript.sleep wscript.Arguments(0)”
objOutputFile.Close
如果结束
CreateObject(“WScript.Shell”)。运行tempFolder&“\”&tempName&“&MSecs,1,True
端接头
'******
子SSID_名称()
Dim objShell、fso、文件、strcontent、objRegEx、objMatch、colMatches
设置objShell=CreateObject(“WScript.Shell”)
设置fso=CreateObject(“Scripting.FileSystemObject”)
如果执行器(“netsh wlan show all>wlan.txt”,0)=0,则
Set File=fso.OpenTextFile(“Wlan.txt”,1)
strContents=File.ReadAll
Set objRegEx=New RegExp
objRegEx.IgnoreCase=True
objRegEx.Global=True
objRegEx.Multiline=True
objRegEx.Pattern=“”([^”“]+)“”
set colMatches=objRegEx.Execute(strContents)
对于colMatches中的每个objMatch
MsgBox“SSID name:&objMatch.Value,64,“SSID name”
下一个
如果结束
端接头
'******
在线功能(strHost)
尺寸对象,z,对象状态,PingStatus
Set objPing=GetObject(“winmgmts:{impersonationLevel=impersonate}”).ExecQuery(“从Win32中选择*,其中地址=””&strHost&“”)
z=0
做
z=z+1
对于objRetStatus中的每个objRetStatus
如果IsNull(objRetStatus.StatusCode)或objRetStatus.StatusCode为0,则
PingStatus=False
其他的
PingStatus=True
如果结束
下一个
睡200
如果z=4,则退出Do
循环直到PingStatus=True
如果PingStatus=True,则
在线=真
其他的
在线=错误
如果结束
端函数
'******
子WLAN_网络()
如果执行器(“netsh wlan show profiles>wlan_tmp.txt&netsh wlan show networks>>wlan_tmp.txt&netsh wlan show interfaces>>wlan_tmp.txt&cmd/U/C Type wlan_tmp.txt>wlan_networks.txt”,0)=则
调用执行器(“启动Wlan_Networks.txt&Del Wlan_tmp.txt”,0)
如果结束
端接头
未列出留置权:

  • 滨海平发展网 帮助苏尔FindStr IpConfig Netstat Arp Tracert
    公共知识产权 SSID无线局域网 无线局域网
    您可以查看以下内容:

    此外,您还可以从这个旧的HTA(法语版本)中得到启发,它允许您从命令行启动一些命令,因此,您可以打开系统上安装的任何浏览器的任何链接

    请尝试一下以下代码:

    <html>
    <head>
    <HTA:APPLICATION
    APPLICATIONNAME="Ouvrir des liens avec les navigateurs IE,Chrome et Firefox"
    BORDER="THIN"
    BORDERSTYLE="NORMAL"
    ICON="Explorer.exe"
    INNERBORDER="NO"
    MAXIMIZEBUTTON="NO"
    MINIMIZEBUTTON="NO"
    SCROLL="NO"
    SELECTION="NO"
    SINGLEINSTANCE="YES"/>
    <META HTTP-EQUIV="MSThemeCompatible" CONTENT="YES">
    <title>Ouvrir des liens avec les navigateurs IE,Chrome et Firefox</title>
    <SCRIPT LANGUAGE="VBScript">
    '******
    Option Explicit
     Function Executer(StrCmd,Console)
     Dim ws,MyCmd,Resultat
     Set ws = CreateObject("wscript.Shell")
    'La valeur 0 pour cacher la console MS-DOS
     If Console = 0 Then
     MyCmd = "CMD /C " & StrCmd & " "
     Resultat = ws.run(MyCmd,Console,True)
     If Resultat = 0 Then
     'MsgBox "Success"
     Else
     MsgBox "Une erreur inconnue est survenue !",16,"Une erreur inconnue est survenue !"
     End If
     End If
    'La valeur 1 pour montrer la console MS-DOS
     If Console = 1 Then
     MyCmd = "CMD /K " & StrCmd & " "
     Resultat = ws.run(MyCmd,Console,False)
     If Resultat = 0 Then
     'MsgBox "Success"
     Else
     MsgBox "Une erreur inconnue est survenue !",16,"Une erreur inconnue est survenue !"
     End If
     End If
     Executer = Resultat
    End Function
    '******
    Sub window_onload()
     CenterWindow 400,320
    End Sub
    '******
    Sub CenterWindow(x,y)
     Dim iLeft,itop
     window.resizeTo x,y
     iLeft = window.screen.availWidth/2 - x/2
     itop = window.screen.availHeight/2 - y/2
     window.moveTo ileft,itop
    End Sub
    '******
    Sub Ip_Publique()
     Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches,ip_public
     Titre = "Adresse Ip Publique !"
     URL = "http://monip.org"
     If OnLine("smtp.gmail.com") = True Then
     Set ie = CreateObject("InternetExplorer.Application")
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     ie.Navigate (URL)
     ie.Visible=False
     DO WHILE ie.busy
     Sleep 100
     Loop
     Data = ie.document.documentElement.innertext
     Set objRegex = new RegExp
     objRegex.Pattern = "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
     objRegex.Global = False
     objRegex.IgnoreCase = True
     Set Matches = objRegex.Execute(Data)
     For Each Match in Matches
     MsgBox "Votre IP Publique est : "& Match.Value,64,Titre
     Next
     ie.Quit
     Set ie = Nothing
     Else
     MsgBox "Vérifier votre connexion internet puis re-executer ce script",48,Titre
     Exit Sub
     End If
    End Sub
    
    '******
    Sub Sleep(MSecs)'Fonction pour faire une pause car wscript.sleep ne marche pas dans un HTA
     Dim fso,objOutputFile
        Set fso = CreateObject("Scripting.FileSystemObject")
        Dim tempFolder : Set tempFolder = fso.GetSpecialFolder(2)
        Dim tempName : tempName = "Sleeper.vbs"
        If Fso.FileExists(tempFolder&"\"&tempName)=False Then
          Set objOutputFile = fso.CreateTextFile(tempFolder&"\"&tempName, True)
          objOutputFile.Write "wscript.sleep WScript.Arguments(0)"
          objOutputFile.Close
        End If
        CreateObject("WScript.Shell").Run tempFolder&"\"&tempName &" "& MSecs,1,True
    End Sub
    '******
    Sub SSID_names()
    Dim objShell,fso,File,strContents,objRegEx,objMatch,colMatches
     set objShell = CreateObject("WScript.Shell")
     Set fso = CreateObject("Scripting.FileSystemObject")
     If Executer("netsh wlan show all > Wlan.txt",0) = 0 Then
     Set File = fso.OpenTextFile("Wlan.txt",1)
     strContents = File.ReadAll
     Set objRegEx = New RegExp
     objRegEx.IgnoreCase = True
     objRegEx.Global = True
     objRegEx.Multiline = True
     objRegEx.Pattern = """([^""]+)"""
     set colMatches = objRegEx.Execute(strContents)
     For each objMatch in colMatches
     MsgBox "SSID name: " & objMatch.Value,64,"SSID name"
     Next
     End If
    End sub
    '******
    Function OnLine(strHost)
    Dim objPing,z,objRetStatus,PingStatus
        Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & strHost & "'")
        z = 0
        Do   
          z = z + 1
          For Each objRetStatus In objPing
          If IsNull(objRetStatus.StatusCode) Or objRetStatus.StatusCode <> 0 Then
                PingStatus = False
          Else
                PingStatus = True
          End If     
        Next   
          sleep 200
          If z = 4 Then Exit Do
        Loop until PingStatus = True
        If PingStatus = True Then
          OnLine = True
        Else
          OnLine = False
        End If
    End Function
    '******
    Sub WLAN_Networks()
     If Executer("netsh wlan show profiles > Wlan_tmp.txt & netsh wlan show networks >> Wlan_tmp.txt & netsh wlan show interfaces >> Wlan_tmp.txt & cmd /U /C Type Wlan_tmp.txt > Wlan_Networks.txt",0) = 0 Then
     Call Executer("Start Wlan_Networks.txt & Del Wlan_tmp.txt",0)
     End If
    End Sub
    </script>
    </head>
    <p>Une liste de liens :</p>
    <ol>
    <li><a href="#" onClick="Call Executer('Start iexplore.exe www.google.com',0)">Lien Google avec iexplore.exe</a></li>
    <li><a href="#" onClick="Call Executer('Start chrome.exe http://bbat.forumeiro.com/',0)">Lien BBAT avec Chrome.exe</a></li>
    <li><a href="#" onClick="Call Executer('Start Firefox.exe www.developpez.net',0)">Lien developpez.net avec Firefox.exe</a></li>
    <li><a href="#" onClick="Call Executer('Start chrome.exe www.yahoo.fr',0)">Lien Yahoo avec Chrome.exe</a></li>
    <li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.fr',0)">Lien Autoitscript.fr (Français) avec Chrome.exe</a></li>
    <li><a href="#" onClick="Call Executer('Start chrome.exe www.autoitscript.com',0)">Lien autoitscript.com (Anglais) avec Chrome.exe</a></li>
    <li><a href="#" onClick="Call Executer('Start www.sfr.fr',0)">Lien SFR avec votre navigateur par défaut</a></li>
    </ol>
    <BODY text=white bgcolor="DarkOrange" TOPMARGIN="1" LEFTMARGIN="1">
     <center><button onclick="Call Executer('mode con cols=90 lines=15 & Color 0A & Title Ping sur www.developpez.net by Hackoo & Ping www.developpez.net',1)">Ping sur developpez.net</button>
     <center><button onclick="Call Executer('FindStr /? > HelpFindStrTmp.txt & cmd /U /C Type HelpFindStrTmp.txt > HelpFindStr.txt & start HelpFindStr.txt',0)">Help sur FindStr</button>
     <button onclick="Call Executer('ipconfig /all > configTmp.txt & cmd /U /C Type configTmp.txt > MyIPconfig.txt & start MyIPconfig.txt',0)">IpConfig</button>
     <button onclick="Call Executer('mode con cols=80 lines=50 & Color 9B & Title Hackoo & netstat -a',1)">Netstat</button>
     <button onclick="Call Executer('mode con cols=60 lines=10 & Color 0A & Title Hackoo & arp -a',1)">Arp</button>
     <button onclick="Call Executer('mode con cols=80 lines=30 & Color 9B & Title Tracert vers www.developpez.com by Hackoo & Tracert www.developpez.com',1)">Tracert</button><br>
     <center><button onclick="Call Ip_Publique">IP Publique</button>
     <button onclick="Call SSID_names()">SSID WLAN</button>
      <button onclick="Call WLAN_Networks()">WLAN Network</button>
     </center>
     </center>
    </body>
    </html> 
    
    
    浏览器、浏览器和火狐浏览器
    '******
    选项显式
    功能执行器(StrCmd、控制台)
    Dim ws、MyCmd、Resultat
    设置ws=CreateObject(“wscript.Shell”)
    'La valeur 0倒在控制台上
    
    webBrowser.Navigate "https://google.co.uk/"