2017-09-01 198 views
2

我有一個PowerShell腳本,用於打開Internet Explorer中的某個鏈接。到目前爲止,我有以下代碼。它會打開鏈接,但當我特別需要它在Internet Explorer中打開時,它會發送到我的默認瀏覽器。如何爲Internet Explorer創建URL快捷方式

$Shell = New-Object -ComObject ("WScript.Shell") 
$ShortCut = $Shell.CreateShortcut($env:USERPROFILE + "\Desktop\TMW.lnk") 
$ShortCut.TargetPath="http://tmw1.casttrans.com/rdweb" 
$ShortCut.WorkingDirectory = "C:\Program Files (x86)\Internet Explorer"; 
$ShortCut.WindowStyle = 1; 
$ShortCut.IconLocation = "iexplore.exe, 0"; 

$ShortCut.Save() 
+0

而不是做一個URL快捷方式,你需要做一個'iexplore.exe'的快捷方式並將網站作爲參數傳遞。 – BenH

回答

2

使用默認瀏覽器打開URL快捷方式。要使用特定瀏覽器打開,您需要調用該應用程序並將其傳遞給網頁。特別是,iexplore.exe將打開在第一個參數中傳遞的網頁。

$Shell = New-Object -ComObject ("WScript.Shell") 
$ShortCut = $Shell.CreateShortcut($env:USERPROFILE + "\Desktop\TMW.lnk") 
$ShortCut.TargetPath = "C:\Program Files (x86)\Internet Explorer\iexplore.exe" 
$ShortCut.Arguments = "http://tmw1.casttrans.com/rdweb" 
$ShortCut.WorkingDirectory = "C:\Program Files (x86)\Internet Explorer"; 
$ShortCut.WindowStyle = 1; 
$ShortCut.IconLocation = "iexplore.exe, 0"; 

$ShortCut.Save()