Forum Discussion
Powershell script is not working using PSF
- Jul 21, 20221) The PsfScriptLauncher.ps1 file is missing from the root of the package. This file is part of the PSF. This file is required as it will be executed in PowerShell to then run your script.
2) The timeout value in the Json is too low. The 10 represents 10ms which is generally not long enough for PowerShell to even start up. Increase to 10000 to get 10 seconds, for example.
3) Add a sleep to the end of the powershell start-sleep 60 would give you time to see any error messages in the PowerShell window should they occur. If so, the timeout value will have to increase more.
4) The Unrestricted option in the json will cause a problem if there is any GPO setting the PowerShell restriction policy. As is in your ps1 file, the Bypass option might be a better choice
5) If you still have issues, use the Sysinternals DebugView tool which can display debugging information emitted by the PsfLauncher as it tries to start your script. Start that tool, then launch the shortcut.
TIMOTHY_MANGAN , Aniket_Banerjee I am attaching few screenshots, please check if I am making any mistakes here.
2) The timeout value in the Json is too low. The 10 represents 10ms which is generally not long enough for PowerShell to even start up. Increase to 10000 to get 10 seconds, for example.
3) Add a sleep to the end of the powershell start-sleep 60 would give you time to see any error messages in the PowerShell window should they occur. If so, the timeout value will have to increase more.
4) The Unrestricted option in the json will cause a problem if there is any GPO setting the PowerShell restriction policy. As is in your ps1 file, the Bypass option might be a better choice
5) If you still have issues, use the Sysinternals DebugView tool which can display debugging information emitted by the PsfLauncher as it tries to start your script. Start that tool, then launch the shortcut.
- SJamal85Jul 29, 2022Copper Contributor
hi TIMOTHY_MANGAN : just out of curiosity, does MSIX also support VB script or now all required scripting needs to be done through Powershell only with MSIX?
- Jul 29, 2022
SJamal85 It must be Powershell. You can provide a PS wrapper script that calls a VB Script.
- sebastianpehlkeSep 13, 2023Copper Contributor
i have a question regarding a powershell script in my msix package. i want to copy files from the windowsapps folder to appdata.
i added the script and also all psf files into the root of the package. When i start the application it says me
i tried Set-ExecutionPolicy -ExecutionPolicy ByPass -Scope Currentuser -Force and Set-ExecutionPolicy -ExecutionPolicy ByPass -Scope LocalMachine -Force in the package but it doesnt work.
what is my fault? Can you help?
thanks and best regards
- SJamal85Jul 25, 2022Copper ContributorThanks for your inputs. My package finally worked as expected 🙂