Page 1 of 1

Why is this script not working?

Posted: 29 Jan 2017 05:32
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");

Re: Why is this script not working?

Posted: 29 Jan 2017 06:09
by highend
Google for: executionpolicy powershell...

Re: Why is this script not working?

Posted: 29 Jan 2017 06:17
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

Re: Why is this script not working?

Posted: 29 Jan 2017 07:31
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");

Re: Why is this script not working?

Posted: 30 Jan 2017 04:19
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

Re: Why is this script not working?

Posted: 30 Jan 2017 04:36
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.