如何为Internet Explorer创建URL快捷方式

时间:2017-09-01 16:57:45

标签: powershell internet-explorer shortcut

我有一个PowerShell脚本,可以打开Internet Explorer中的某个链接。到目前为止,我有以下代码。它会打开链接,但是当我特别需要它在Internet Explorer中打开时,它会发送到我的默认浏览器。

$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()

1 个答案:

答案 0 :(得分:4)

使用默认浏览器打开网址快捷方式。要使用特定浏览器打开,您需要调用该应用程序并将其传递给网页。特别是,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()