Reputation: 35
Due to the fact that I have to boot up a lot of applications and a Chrome browser and I can't just autostart them because it all depends on which network I'm connected to, I'm writing a short PowerShell script. It's basically a bunch of invoke-items and then this thing
$urls = "my.intranet.com", "www.google.com", "www.microsoft.com"
start "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Foreach ($url in $urls)
{
start $url
}
These aren't the actual URLs, but you get the picture.
Now, whenever I do this, I get one extra tab in Chrome. It's the default empty tab of Chrome. While not hugely annoying, it's pretty ugly.
How do I tell my Powershell to close an empty tab labelled "New Tab" in Chrome?
Upvotes: 0
Views: 3319
Reputation: 4838
Instead of closing the empty tab, just start the browser with only the tabs you want.
To do this, pass the URLs as arguments to chrome.exe
:
$urls = "my.intranet.com", "www.google.com", "www.microsoft.com"
Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -ArgumentList $urls
Edit: Adding opening in new window, as asked for in the comments
If you want Chrome to a new window for the tabs, just specify the --new-window
switch as well as the URLs, like so:
$arguments = "--new-window", "my.intranet.com", "www.google.com", "www.microsoft.com"
Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -ArgumentList $arguments
Upvotes: 2