0

I'm trying to run this script by double clicking the file:

    $notifyParams = @{title="XXXX";content="New Tasks Available!"}
Invoke-WebRequest -Uri https://hook.notify17.net/api/raw/XXXXX -Method POST -Body $notifyParams

I want another program to activate it automatically so Right-click> Run with Powershell won't help me.

I have tried everything suggested in this thread, nothing seems to help: Is there a way to make a PowerShell script work by double clicking a .ps1 file?

Only Right-click> Run with Powershell actually runs the script.

I have no actual knowledge in PowerShell and I did not wrote it myself, I just need to run it.

NoamC
  • 1
  • 1

1 Answers1

0

I changed the group policy for the execution policy (https://stackoverflow.com/a/27753927/15681745) and it worked with a cmd file with this script

    ::====================================================================
:: Powershell script launcher
::=====================================================================
:MAIN
    @echo off
    for /f "tokens=*" %%p in ("%~p0") do set SCRIPT_PATH=%%p
    pushd "%SCRIPT_PATH%"

    powershell.exe -sta -c "& {.\%~n0.ps1 %*}"

    popd
    set SCRIPT_PATH=
    pause
NoamC
  • 1
  • 1
  • If the execution policy was the problem then you can just use `-ExecutionPolicy Bypass` on your shortcut unless you actually want to run your script with cmd – Santiago Squarzon Apr 19 '21 at 01:31