none
Same Powershell script is NOT when double click in the path D:\My Documents\Softwares\PowerShell RRS feed

  • General discussion

  • Hello friends,

    I configured to execute poweshell scripts when I double click them. But they are NOT WORKING when I double click on them when the scripts are in the path or folder D:\My Documents\Softwares\PowerShell. But they are working when I call them thru Powershell console. But if I double click the same, they are not working. I tried by creating profile.ps1 too but no luck

    But they are WORKING when I double click when they are in the folder  C:\Scripts or D:\Scripts. 

    I know the difference is space between MY Documents. Is there any way they can work in the path D:\My Documents\Softwares\PowerShell  with double click? I am not looking to call from batch file or vbscript. :-)

    • Changed type Bill_Stewart Friday, January 26, 2018 6:37 PM
    • Moved by Bill_Stewart Friday, January 26, 2018 6:38 PM This is not "teach me Windows shell basics" forum
    Monday, December 25, 2017 1:02 PM

All replies

  • By default PowerShell scripts cannot be double clicked. If you installed some third party software or modified you system then you will have to have someone from the vendor or who showed you how to modify the system help you.

    \_(ツ)_/

    Monday, December 25, 2017 1:13 PM
  • Hello Jrv. Thanks for your time.

    I agree with you by default Powershell scripts cannot be double clicked. I am not using any tools.

    By using the forums like this I made it working when I double click on the script if the scripts are in folder like D:\Scripts or D:|WindowScripts\  etc., But if the scripts are in a folder My Documents which have a space and hence giving the issue. Being a novice, Not sure how to make it work. Hence approached the forum friends.

    Monday, December 25, 2017 2:54 PM
  • Sorry but we cannot guess at what you may have done. You will have to find the forum that helped you are ask a trained tech to help you fix this.  It is not a scripting issue. It is a system configuration issue.


    \_(ツ)_/

    Monday, December 25, 2017 2:58 PM
  • Hi

    One workaround would be, if you don't want to fiddle around with your computer environment settings, to compile your .ps1 file to .exe file by using PowerGUI or similar tools. This will definitely let you double click and run the executable file. Well, at least, that's how I do it.


    • Edited by Naw Monday, December 25, 2017 5:56 PM
    Monday, December 25, 2017 5:56 PM
  • Hello Naw... Thanks for your time.

    Yep.. I know that exe workaround is working. But really I am very curious how to make the script to work from my documents folder. If you have any suggestions to modify with my computer environment, I am ready to do ON MY OWN RISK. Thanks in advance and appreciate your time.

    Monday, December 25, 2017 8:24 PM
  • To run a PowerShell script by double-clicking on it: Create a shortcut with the following properties.

    Command: %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

    Parameters: -ExecutionPolicy Bypass -File "C:\Script Path\Script Name.ps1" -Argument [...]

    Double-click on the shortcut.


    -- Bill Stewart [Bill_Stewart]

    Monday, December 25, 2017 10:14 PM
  • If I were you, I would just create a shortcut with the necessary parameter for the ps1 script file as such.

    Right Click on Windows Explorer, New, ShortCut and copy and paste something like below. adjust it as necessary.

    powershell.exe -command "& 'C:\Users\Username\Documents\MyScript.ps1' -MyArguments blah"

    You can now double-click on the shortcut and run your script that way.  Hope this helps!


    • Edited by Naw Monday, December 25, 2017 10:18 PM
    Monday, December 25, 2017 10:17 PM
  • The -Command parameter is no longer necessary now that we have -File. See my answer.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, December 26, 2017 5:31 PM
  • where I need to put parameters, I didn't see any tab with parameters.
    Tuesday, December 26, 2017 7:41 PM
  • It is not necessary to double click or create any shortcuts.  In File Explorer just right click any PS1 file and select "Run with PowerShell"


    \_(ツ)_/

    Tuesday, December 26, 2017 7:45 PM
  • interesting... Thanks JRV

    Surprisingly, in file explorer (right click on Start, click start windows explorer then navigated to My Documents. Then when I double click it worked. Not sure why when navigate in general way from Desktop, its not working.

    Tuesday, December 26, 2017 7:53 PM
  • The desktop is not part of File Explorer.  It is a special namespace.

    Right click on ps1 file on desktop and select "Run with Powershell"


    \_(ツ)_/

    Tuesday, December 26, 2017 7:58 PM