Launch a Powershell script

  1. 9 months ago

    Bill S

    31 Aug 2019 Xojo Pro
    Edited 9 months ago

    My program builds a powershell script and saves it to the temp folder as 'MyScript.ps1'.

    How can I shell/run/launch it?

  2. Wayne G

    1 Sep 2019 Testers, Xojo Pro, MVP Auckland, New Zealand

    Create a Shell and execute the command "Powershell.exe -File %temp%\myscript.ps1"

  3. Tim J

    1 Sep 2019 Testers, Xojo Pro N. Phoenix, AZ

    Note that you may need to provide the full path to the PowerShell.exe app depending on your Windows setup. On my systems that maps to:

    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  4. One of many PowerShell security features is that you can't run a script simply by double clicking it's icon on desktop or in a folder.
    1.) Right click a script, select Create shortcut
    2.) Right click the shortcut, select Properties
    3.) The Target field under Shortcut tab shows full path to file this shortcut will open
    5.) At the moment shortcut would act exactly as the script icon, open script in Notepad for editing.
    \then save it by OK nd execute the command "Powershell.exe -File %temp%\myscript.ps1"
    its simple.

or Sign Up to reply!