我有一个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()

最佳答案

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

关于powershell - 如何为Internet Explorer创建URL快捷方式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46004906/

10-10 06:42