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 -
}
}
})
Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)
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.
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.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)
[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)
You cannot start Microsoft Edge from the command line and Edge does not take a URL as an argument.
Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)
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
start-process msedge
start-process msedge http://google.com
Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)
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.
#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.
Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)
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.
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.
Re: Powershell execution policy blocks opening of a website (exe systray icon created via ps studio)
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"