7

I want to execute a powershell script (ps1-file) with a hotkey on my keyboard (CTRL + SHIFT + F for instance).

I managed to create a shortcut of the script (right click in explorer > new > shortcut). The shortcut's target is: "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "PATH_TO_THE_SCRIPT" ".

When I execute the script manually (by double-clicking the shortcut), it works like a charm. But when I try to assign a "Shortcut key" in the Shortcut Properties (CTRL + SHIFT + F) and press the shortcut key I just defined, nothing happens. What's the matter?

I'm quite sure it has something to do with security policies. But I don't know what exactly it is.

This is my Execution-Policy:

Scope ExecutionPolicy
----- ---------------
MachinePolicy  Undefined
UserPolicy     Undefined
Process        RemoteSigned
CurrentUser    Unrestricted
LocalMachine   Unrestricted

Any help is appreciated.

1
  • 1
    The shortcut should be inside Start Menu or on the Desktop. Anyway, first ensure your Explorer is not broken by using calc as a target of the shortcut. Commented Sep 24, 2016 at 14:38

2 Answers 2

5

That's it. As soon as I move the shortcut file to the desktop and redefine the "shortcut key", the shortcut key works!

Is there a particular reason, why the shortcut has to be on the desktop?

Sign up to request clarification or add additional context in comments.

1 Comment

Correct. This is only a guess, but I assume search performance is the reason
-1

Fist start PowerShell with run as administrator . then type this command on it :

Set-ExecutionPolicy Bypass -Force

after this you can run all script.

remember if you use Powershell_ise (IDE for powershell) don't use 86x when you're OS is 64 bit.and if you're directory in desktop you should fist set you're directory with :

cd "enter desktop directory"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.