You already have a lnk
that points to your script file. Make that point to PowerShell and pass your file as a parameter. Assuming your file is located in C:\PSScripts
you would have to set the Target of the lnk
to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& C:\PSScripts\Display Off.ps1" -NoLogo -NonInteractive -NoProfile
So, you can't run PS script, because security feature. User can't double click it. You can create simple.bat like:
powershell -command Set-ExecutionPolicy RemoteSigned
powershell -command Your Script
powershell -command Set-ExecutionPolicy Restricted
Check too this topic: Is there a way to make a PowerShell script work by double clicking a.ps1 file? There are more solutions there.
Go to the General
tab in your shortcut settings, and change the Open with
row from notepad
to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.