如何为Internet Explorer创建URL快捷方式
问题描述:
我有一个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()
答
使用默认浏览器打开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()
而不是做一个URL快捷方式,你需要做一个'iexplore.exe'的快捷方式并将网站作为参数传递。 – BenH