PowerShell script will not run from within XYplorer

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

PowerShell script will not run from within XYplorer

Post by zBernie »

I have a one-line powershell script named myhost.ps1, which is shown below. If I run the script from the the PowerShell command line, it works. If I run it using Start/Run, it works. If I run the script from Explorer, it also works. But if I run it from within XYplorer by double clicking on it, a message flashes, and then it exits.

I have the execution policy set to unrestricted for PowerShell. Any ideas why this will not run from XYplorer?



bash -c "ssh zbernie@myhost"

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

Re: PowerShell script will not run from within XYplorer

Post by highend »

a message flashes
And you don't think that this could be a vague hint?
One of my scripts helped you out? Please donate via Paypal

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

Re: PowerShell script will not run from within XYplorer

Post by zBernie »

highend wrote:
a message flashes
And you don't think that this could be a vague hint?
It's probably more than a vague hint, but unfortunately as I said, it is displayed for a split second, then disappears. If I could read it I'm sure I would have better insight into the problem.

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

Re: PowerShell script will not run from within XYplorer

Post by highend »

Capture the screen, scroll in the preview of that video where the message appears, make a screenshot?

http://www.donationcoder.com/Software/Mouser/esr/
One of my scripts helped you out? Please donate via Paypal

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

Re: PowerShell script will not run from within XYplorer

Post by zBernie »

highend wrote:Capture the screen, scroll in the preview of that video where the message appears, make a screenshot?

http://www.donationcoder.com/Software/Mouser/esr/
First I added a try/catch block to the powershell script, in order to capture the error to a file like this:

try
{
C:\WINDOWS\system32\bash.exe -c "ssh zbernie@myhost"
}
catch [Exception]
{
echo $error | Out-File C:\Users\bernie\PowerShell\Terminals\pshell.log
}


The error below is output to the pshell.log file. I added the full path to bash.exe and still get the error when I run the script from XYplorer. As I said, I can run the script from Windows Explorer, and it runs without error. It also runs without error from the command line. Any idea why bash.exe is not found when the powershell script is fun from XYplorer?


C:\WINDOWS\system32\bash.exe : The term 'C:\WINDOWS\system32\bash.exe' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At C:\Users\bernie\PowerShell\Terminals\sis-app2-prod.ps1:4 char:7
+ C:\WINDOWS\system32\bash.exe -c "ssh bartonbf@sis-app2-prod"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\system32\bash.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

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

Re: PowerShell script will not run from within XYplorer

Post by highend »

Probably because of

Code: Select all

rtfm "idh_wow64.htm";
Execute it from the address bar
One of my scripts helped you out? Please donate via Paypal

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

Re: PowerShell script will not run from within XYplorer

Post by zBernie »

highend wrote:Probably because of

Code: Select all

rtfm "idh_wow64.htm";
Execute it from the address bar
I tried from the address bar and it does not seem to execute at all. I included the full path to a script like:

C:\Users\bernie\PowerShell\Terminals\sis-TESTING.ps1

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

Re: PowerShell script will not run from within XYplorer

Post by highend »

?

You are supposed to execute the rtfm command from the address bar...
One of my scripts helped you out? Please donate via Paypal

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

Re: PowerShell script will not run from within XYplorer

Post by zBernie »

highend wrote:?

You are supposed to execute the rtfm command from the address bar...
Oops! Well, I finally read the fine manual regarding WOW64 redirection. It says that as long as you have this check box ticked:

"Show the real System32 directory"

The rest of the article is just for reference. I already had that check box ticked. I tried unticking it, and checking others, and still cannot run the PowerScript file from XYplorer. Any other suggestions?

-Thanks

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

XYPlorer unable to see C:\WINDOWS\system32\bash.exe

Post by zBernie »

I have a PowerShell script which calls C:\WINDOWS\system32\bash.exe. This script runs ok from Windows Explorer, and also runs ok from the command line. But when I run it from XYplorer, I get the error below in red stating CommandNotFoundException. I've tried checking and unchecking the shell integration options to "Show the real System32 directory" and "Show the 64-bit context menu, but I still get the error.

Can anyone suggest how to circumvent this issue of XYplorer's inability to see C:\WINDOWS\system32\bash.exe?

-Thanks



MYSCRIPT.PS1

try
{
C:\WINDOWS\system32\bash.exe -c "ssh zbernie@myhost"
}
catch [Exception]
{
echo $error | Out-File C:\Users\bernie\PowerShell\Terminals\pshell.log
}



ERROR:

C:\WINDOWS\system32\bash.exe : The term 'C:\WINDOWS\system32\bash.exe' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At C:\Users\bernie\PowerShell\Terminals\sis-app2-prod.ps1:4 char:7
+ C:\WINDOWS\system32\bash.exe -c "ssh zbernie@myhost"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\WINDOWS\system32\bash.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

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

Re: PowerShell script will not run from within XYplorer

Post by highend »

Merged.
The rest of the article is just for reference
Read the part for the sysnative folder...
One of my scripts helped you out? Please donate via Paypal

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

Re: PowerShell script will not run from within XYplorer

Post by zBernie »

highend wrote:Merged.
The rest of the article is just for reference
Read the part for the sysnative folder...

I followed the docs and it does not work for me:

"Note: To enable the Sysnative solution you first have to create an empty new folder C:\Windows\Sysnative. Then you can go to e.g. C:\Windows\Sysnative\drivers to access the 64-bit C:\Windows\System32\drivers."

PS C:\WINDOWS\system32> mkdir C:\Windows\Sysnative

Directory: C:\Windows

Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 3/2/2017 10:29 PM Sysnative


PS C:\WINDOWS\system32> Get-ChildItem C:\Windows\Sysnative\drivers
Get-ChildItem : Cannot find path 'C:\Windows\Sysnative\drivers' because it does not exist.
At line:1 char:1
+ Get-ChildItem C:\Windows\Sysnative\drivers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Windows\Sysnative\drivers:String) [Get-ChildItem], ItemNotFoundExcep
tion
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand :D

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

Re: PowerShell script will not run from within XYplorer

Post by highend »

Note that 64-bit applications cannot use the Sysnative alias as it is a virtual directory not a real one
And you are in a 64-bit powershell window...

Now, what happens when you change your

Code: Select all

C:\WINDOWS\system32\bash.exe -c "ssh zbernie@myhost"
to

Code: Select all

bash.exe -c "ssh zbernie@myhost"
restart XYplorer
and execute it from there again?

On this system, it works...
One of my scripts helped you out? Please donate via Paypal

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

Re: PowerShell script will not run from within XYplorer

Post by zBernie »

highend wrote:
Note that 64-bit applications cannot use the Sysnative alias as it is a virtual directory not a real one
And you are in a 64-bit powershell window...

Now, what happens when you change your

Code: Select all

C:\WINDOWS\system32\bash.exe -c "ssh zbernie@myhost"
to

Code: Select all

bash.exe -c "ssh zbernie@myhost"
restart XYplorer
and execute it from there again?

On this system, it works...
Really, it works for you on Windows 10? I had one line in my powershell script:

bash.exe -c "vim"

And I got the error below.


bash.exe : The term 'bash.exe' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\bernie\PowerShell\Terminals\sis-TESTING.ps1:3 char:7
+ bash.exe -c "vim"
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (bash.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

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

Re: PowerShell script will not run from within XYplorer

Post by highend »

Really, it works for you on Windows 10?
Exactly
powershell.gif
powershell.gif (99.63 KiB) Viewed 1870 times
One of my scripts helped you out? Please donate via Paypal

Post Reply