2009-06-16 45 views
1

我需要在IE中運行Web應用程序,所以它至少看起來類似於獨立應用程序。我還需要能夠在單獨的會話中同時運行此Web應用程序的多個實例。在沒有工具欄的新流程中啓動Internet Explorer 7

爲了實現這種效果,我希望始終在新的進程中啓動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沒有工具欄/狀態欄從桌面上的快捷方式?

我接受任何種類的解決方案技術。

感謝, 埃弗裏特

回答

1

沒有其他的答案對我來說,所以這裏是一個我從各種來源拼湊起來的vb腳本(我不是vb scripter)。

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 

我願意接受任何改進或建議。

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。

+0

感謝您的建議,但是當我嘗試此操作時,我的頁面上的JavaScript出現了問題(其中大部分我甚至無法觸及)。 – 2009-06-17 23:50:03

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即-app.ps1」 來調用它。

這與您在vbscript中使用Windows腳本宿主所做的基本相同。您可以使用任何可以操縱InternetExplorer.Application COM對象的東西。我有IE8,它可能只是IE7和IE8之間的差異,但與我的PowerShell示例,我得到兩個進程。

+0

感謝您的建議,但是當我使用Windows XP和IE7嘗試此操作時,我仍然只獲得1個進程。 – 2009-06-17 18:23:30

+0

乾杯,爲此工作。 – 2011-01-24 10:11:29

1

您沒有指定您希望使用哪種編碼方式來完成此操作,但您無疑會想要查看WebBrowser Class

相關問題