Windows 10 Open links in Microsoft Edge using .vbs script

Carenn12

Member
Joined
Aug 11, 2020
Messages
8
Currently I am using this script to open links in Chrome:

Code:
Sub Chrome(URL)

'----------------------------------------------------------------------

' Purpose: Launch Chrome

' Arguments: <URL>

'----------------------------------------------------------------------

if (ubound(split(URL," ")) = 0) then

Dim objShell

Set objShell = CreateObject("Shell.Application")

objShell.ShellExecute "chrome.exe", URL, "", "", 1

end if

end Sub

Is it possible to open this in Microsoft Edge? I tried replacing shellExecute line with this objShell.ShellExecute "microsoft-edge:", URL, "", "", 1, but that just opens the Edge with home page, and not the `URL`. Any tips?
 


Solution
Thanks! Had to do some small adjustments, but this works like a charm:
Code:
Dim shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run """" & "microsoft-edge:" & URL & """"
Set objShell = CreateObject("WScript.Shell")
objShell.Run "msedge URL"
should work
 


Works for me, what version of Windows? Can you use powershell instead?
 


It's depends how it needs to be called.

If it's a hard coded call then like this
Code:
Start-Process -FilePath "msedge" -ArgumentList "https://google.com"
 


It's depends how it needs to be called.

If it's a hard coded call then like this
Code:
Start-Process -FilePath "msedge" -ArgumentList "https://google.com"
So like this?:

Code:
Sub Chrome(URL)
'----------------------------------------------------------------------
'   Purpose: Launch Chrome
' Arguments: <URL>
'----------------------------------------------------------------------
if (ubound(split(URL," ")) = 0) then
  Start-Process -FilePath "msedge" -ArgumentList "URL"
end if
end Sub
 


No you're mixing vbs and powershell. It's just the one line
 


No you're mixing vbs and powershell. It's just the one line
But there are multiple function in my .vbs file that contains lines like this:
Code:
Chrome "https://domain.my.salesforce.com/apex/ScreenPopView?nr=&cID=" + Params.ParamByName("cID") + "&crpnr=" + NR

And that
Code:
Chrome
is connected and runs by the
Code:
Sub Chrome(URL)
. Do you mean I should replace that Chrome in front of the link with this line:
Code:
Start-Process -FilePath "msedge" -ArgumentList
That does not pop the url.
 


Visual Basic and PowerShell are different languages you can't mix the code in a script. I was suggesting to just convert your code to Powershell, it's much simpler to write.
 


Visual Basic and PowerShell are different languages you can't mix the code in a script. I was suggesting to just convert your code to Powershell, it's much simpler to write.
The .vbs file is 4000 lines of code, so I was hoping to find a easier solution.
 


Some slight modification to the original code I suggested (VBS)

Code:
Dim URL
URL = "https://google.com"
Dim shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run """" & "microsoft-edge://" & URL & """"
 


Thanks! Had to do some small adjustments, but this works like a charm:
Code:
Dim shell
Set Shell = CreateObject("WScript.Shell")
Shell.Run """" & "microsoft-edge:" & URL & """"
 


Solution
Probably a difference in Windows 10 versions. Both microsoft-edge: and microsoft-edge:// work on mine
 


Still would be a good learning opportunity to convert that script to powershell. I imagine that 4000+ line script would end up half the size maybe less.
 


Back
Top