📎 AI Summary:
The thread discusses how to modify a script originally designed to open links in Chrome to instead open them in Microsoft Edge. The original poster tries different methods, including using `ShellExecute` and `Run`, but encounters issues with launching URLs correctly in Edge. A respondent suggests using PowerShell's `Start-Process` with the appropriate arguments, but the original poster clarifies that their script is in VBScript and is calling a subroutine with URLs. The main conclusion is that integrating PowerShell commands into VBScript requires careful handling, and the user needs to adapt their script accordingly to successfully open URLs in Edge. The overall sentiment indicates troubleshooting and experimentation to achieve proper URL launches within their scripting environment.

Carenn12

Member
Member details
Joined
Aug 11, 2020
Messages
8
Thread Author #1
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 & """"

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
Set objShell = CreateObject("WScript.Shell")
objShell.Run "msedge URL"
should work
 

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
Works for me, what version of Windows? Can you use powershell instead?
 

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
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
Member details
Joined
Aug 11, 2020
Messages
8
Thread Author #8
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
 

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
No you're mixing vbs and powershell. It's just the one line
 

Carenn12

Member
Member details
Joined
Aug 11, 2020
Messages
8
Thread Author #10
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

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
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.
 

Carenn12

Member
Member details
Joined
Aug 11, 2020
Messages
8
Thread Author #12
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.
 

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
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
Member details
Joined
Aug 11, 2020
Messages
8
Thread Author #14
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

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
Probably a difference in Windows 10 versions. Both microsoft-edge: and microsoft-edge:// work on mine
 

Neemobeer

Windows Forum Team
Staff member
Member details
Joined
Jul 4, 2015
Messages
8,995
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.