Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 1 year and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Post by stevens »

Hi,

Quick question: I have a systray icon created via a ps1 to exe.
That works fine. Now I have a right click option which opens a website. Thought that is blocked by powershell policy.
Is there a way to bypass without the need of set-executionpolicy (make an exe of that action I'd like to avoid)?

---the code which calls for a website (but is blocked through powershell policy)---
$Main_Tool_Icon.Add_Click({

If ($_.Button -eq [Windows.Forms.MouseButtons]::Left)
{
$URL = "https://www.mylink.com"


try
{
#start-process microsoft-edge:$URL #not working
"start-process microsoft-edge:$URL" | PowerShell.exe -noprofile - #not working either
}
catch
{
#Default browser
#Start-Process $URL
"start-process $URL" | PowerShell.exe -noprofile -
}

}
})
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Post by jvierra »

You cannot start Microsoft Edge from the command line and Edge does not take a URL as an argument.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Post by jvierra »

As far as I can tell this is the only way to start MSEDGE from PS.

start-process msedge
start-process msedge http://google.com
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Post by stevens »

see my post
#start-process microsoft-edge:$URL #not working whereas it works in a normal Powershell Window.
Also note that if I set the set-executionpolicy to unrestricted on a system, the link opens without problem.
So it is a Powershell security issue.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Post by jvierra »

There is still not enough clear info to understand what you are seeing.

Clearly the policy on the failing system is set to some level of restriction. List all of the policies. It is likely that some policy is set to restrict unsigned scripts. I recommend using "MSEDGE" as I posted as it runs the executable directly. Your method parses the string as a URL directly and likely behave like an unsigned script. MSEDGE launches the executable which is signed. A signed executable will launch even when ALLSIGNED is set. I suspect that even when you run an EXE at a prompt you can do it even if scripts are restricted. PS default to the same behavior as CMD which does not restring EXEs and the OS restricts EXEs that are not signed. PS does not check EXEs either. PS only checks scripts.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)

Post by stevens »

Thanks, but when I run msedge https://mylink, I get "msedge : The term 'msedge' is not recognized as the name of a cmdlet, function, script file"
This topic is 1 year and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked