首页 文章

在没有工具栏的新进程中启动Internet Explorer 7

提问于
浏览
1

我需要在IE中运行一个Web应用程序,所以它至少看起来类似于一个独立的应用程序 . 我还需要能够在单独的会话中同时运行此Web应用程序的多个实例 .

为了实现这一目标,我希望始终在一个新的过程中启动Internet Explorer 7,而不需要工具栏/状态栏来自桌面上的快捷方式 .

我尝试了一些事情 . 到目前为止,我所遇到的壁橱是创建以下vb脚本的快捷方式,

Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate "http://stackoverflow.com"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 1024
objExplorer.Height = 768
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1

这看起来就像我想要的那样 . 但是,如果再次双击快捷方式,它会打开一个新窗口但在同一进程内(即Windows任务管理器中只有一个iexplore.exe进程) . 由于这两个实例在同一个进程中,因此它们共享同一个会话 . 因此,如果您登录到应用程序的一个实例,那么您将登录到应用程序的另一个实例,这对我没有好处 .

我也试过了,

"Program Files\Internet Explorer\iexplore.exe" http://stackoverflow.com

它总是启动一个新进程,但你不能只删除工具栏/状态栏 . Kiosk模式(“-k”参数)对我不利,因为我需要它出现在窗口中 .

任何人都可以告诉如何在一个没有工具栏/状态栏的新进程中从桌面上的快捷方式启动Internet Explorer 7吗?

我对解决方案的任何技术持开放态度 .

谢谢,埃弗雷特

4 回答

  • 1

    您可以使用HTML应用程序,如:

    <html>
    <head>
    <title>Stack Overflow</title>
    <hta:application showintaskbar="yes" singleinstance="no" sysmenu="yes" scroll="no"
    icon="http://www.stackoverflow.com/favicon.ico">
    <style type="text/css">
    * { margin: 0px; padding: 0px; }
    iframe { position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; }
    </style>
    </head>
    <body>
    <IFRAME SRC="http://www.stackoverflow.com/" APPLICATION="no">
    </body>
    </html>
    

    然而,如果没有针对HTA的特殊预防措施,这往往会弄乱那里的任何页面的JS .

  • 1

    您可以通过操作IE COM服务器来完成此操作 . 在PowerShell中很容易做到:

    $ie = new-object -COM InternetExplorer.Application
    $ie.ToolBar = $false
    $ie.StatusBar = $false
    $ie.Navigate2( "http://www.stackoverflow.com" )
    $ie.Visible = $true
    

    如果那是在ie-app.ps1中,那么你的快捷方式将有“powershell -command ie-app.ps1”来调用它 .

    这与您在vbscript中使用Windows Scripting Host所做的基本相同 . 您可以使用任何可以操作InternetExplorer.Application COM对象的东西 . 我有IE8,它可能只是IE7和IE8之间的区别,但我的PowerShell示例,我有两个进程 .

  • 1

    您没有指定您希望使用哪种编码方式来完成此任务,但毫无疑问您需要查看WebBrowser Class .

  • 1

    其他答案都没有为我解决,所以这里是一个vb脚本,我从各种来源拼凑而成(我不是一个vb脚本) .

    On Error Resume Next
    
    AppURL = "http://www.stackoverflow.com"
    AppToRun = "iexplore about:blank"
    AboutBlankTitle = "Blank Page"
    LoadingMessage = "Loading stackoverflow..."
    ErrorMessage = "An error occurred while loading stackoverflow.  Please close the Internet Explorer with Blank Page and try again.  If the problem continues please contact IT."
    EmptyTitle = ""
    
    'Launch Internet Explorer in a separate process as a minimized window so we don't see the toolbars disappearing
    dim WshShell
    set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run AppToRun, 6
    
    dim objShell
    dim objShellWindows
    
    set objShell = CreateObject("Shell.Application")
    set objShellWindows = objShell.Windows
    
    dim ieStarted
    ieStarted = false
    
    dim ieError
    ieError = false
    
    dim seconds
    seconds = 0
    
    while (not ieStarted) and (not ieError) and (seconds < 30)
    
        if (not objShellWindows is nothing) then
            dim objIE
            dim IE
    
            'For each IE object
            for each objIE in objShellWindows
    
                if (not objIE is nothing) then
    
                    if isObject(objIE.Document) then
                        set IE = objIE.Document
    
                        'For each IE object that isn't an activex control
                        if VarType(IE) = 8 then
    
                            if IE.title = EmptyTitle then
                                if Err.Number = 0 then
                                    IE.Write LoadingMessage
    
                                    objIE.ToolBar = 0
                                    objIE.StatusBar = 1
                                    objIE.Navigate2 AppURL
    
                                    ieStarted = true
                                else
                                    'To see the full error comment out On Error Resume Next on line 1
                                    MsgBox ErrorMessage
                                    Err.Clear
    
                                    ieError = true
    
                                    Exit For
                                end if
                            end if
                        end if
                    end if
                end if
    
                set IE = nothing
                set objIE = nothing
            Next
        end if
    
        WScript.sleep 1000
        seconds = seconds + 1
    wend
    
    set objShellWindows = nothing
    set objShell = nothing
    
    'Activate the IE window and restore it
    success = WshShell.AppActivate(AboutBlankTitle)
    
    if success then 
        WshShell.sendkeys "% r"  'restore 
    end if
    

    我愿意接受任何改进或建议 .

相关问题