Open links in Microsoft Edge using .vbs script

Carenn12

Member
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?
 

Neemobeer

Application and Cloud Security Engineer
Staff member
Set objShell = CreateObject("WScript.Shell")
objShell.Run "msedge URL"
should work
 

Neemobeer

Application and Cloud Security Engineer
Staff member
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"
 

Carenn12

Member
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
 

Carenn12

Member
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.
 

Neemobeer

Application and Cloud Security Engineer
Staff member
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.
 

Neemobeer

Application and Cloud Security Engineer
Staff member
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 & """"
 

Carenn12

Member
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 & """"
 

Neemobeer

Application and Cloud Security Engineer
Staff member
Probably a difference in Windows 10 versions. Both microsoft-edge: and microsoft-edge:// work on mine
 

Neemobeer

Application and Cloud Security Engineer
Staff member
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.
 
Top