Why is this script not working?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
zBernie
Posts: 181
Joined: 08 Dec 2016 17:20

Why is this script not working?

Post by zBernie »

The simple XY script below runs find on my laptop. But the same script does not work on my desktop. It processes photos in a directory named "Photo Staging" using the processphotos.ps1 PowerShell script. If I run the script manually it works. If I run the entire command below (the part enclosed in quotes) using the Windows run command, it works. If I step through it under the Scripting menu, there are no errors.

Any thoughts as to why it does not work in XYPlorer would be greatly appreciated.


runret("%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe C:\Users\bernie\PowerShell\processphotos.ps1");

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Why is this script not working?

Post by highend »

Google for: executionpolicy powershell...
One of my scripts helped you out? Please donate via Paypal

zBernie
Posts: 181
Joined: 08 Dec 2016 17:20

Re: Why is this script not working?

Post by zBernie »

highend wrote:Google for: executionpolicy powershell...
I already have the ExecutionPolicy set to Unrestricted. Do I need something else to allow XYPlorer to run PS scripts?

Set-ExecutionPolicy Unrestricted

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Why is this script not working?

Post by bdeshi »

Try looking at the output with the text command; you might get hints of the problem.

Code: Select all

::text runret("%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe C:\Users\bernie\PowerShell\processphotos.ps1");
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

zBernie
Posts: 181
Joined: 08 Dec 2016 17:20

Re: Why is this script not working?

Post by zBernie »

SammaySarkar wrote:Try looking at the output with the text command; you might get hints of the problem.

Code: Select all

::text runret("%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe C:\Users\bernie\PowerShell\processphotos.ps1");
Thanks, the ::text showed me the error (shown below). It doesn't make sense. I have the execution policy set to unrestricted, and can run the script processphotos.ps1 as a normal user from the command line. Just not from XYplorer.


C:\Users\bernie\PowerShell\processphotos.ps1 : File C:\Users\bernie\PowerShell\processphotos.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see about_Execution_Policies at
http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ C:\Users\bernie\PowerShell\processphotos.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

zBernie
Posts: 181
Joined: 08 Dec 2016 17:20

Re: Why is this script not working?

Post by zBernie »

SammaySarkar wrote:Try looking at the output with the text command; you might get hints of the problem.

Code: Select all

::text runret("%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe C:\Users\bernie\PowebrShell\processphotos.ps1");
I am now able to execute PS scripts from XYplorer's custom buttons after executing this. I'd prefer a policy which is not unrestricted.

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force;


Thanks for your help.

Post Reply