
Usando Windows 7 e Internet Explorer 9 (o superior), estoy intentando crear un acceso directo en el escritorio a una página web en particular. El truco es que, si el usuario ya tiene esa página web abierta en cualquier ventana de IE, necesito que el acceso directo se centre en esa ventana en lugar de crear una nueva.
Respuesta1
Este script de PowerShell examina todas las URL de IE actuales y, si ninguna tiene Google abierto, abre google.com; de lo contrario, no hace nada. Debe cambiar "*google" por "*yourbaseURLname" y "www.google.com" por "www.yourwebsite.com". (últimas 5 líneas del guión)
Guárdelo como un archivo .ps1.
Function GetCurrentIEURL
{
$IEObjs = @()
$ShellWindows = (New-Object -ComObject Shell.Application).Windows()
Foreach($IE in $ShellWindows)
{
$FullName = $IE.FullName
If($FullName -ne $NULL)
{
$FileName = Split-Path -Path $FullName -Leaf
If($FileName.ToLower() -eq "iexplore.exe")
{
$Title = $IE.LocationName
$URL = $IE.LocationURL
$IEObj = New-Object -TypeName PSObject -Property @{Title = $Title; URL = $URL}
$IEObjs += $IEObj
}
}
}
$IEObjs
}
$CurrentIEURL = GetCurrentIEURL
if ($CurrentIEURL -NotContains "*google")
{
$IE=new-object -com internetexplorer.application
$IE.navigate2("www.google.com")
$IE.visible=$true
}