Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PsCmd2 and powershell ISE Different results
#1
Hi,

The following code execution results are different from those in Powershell ISE. I have encountered similar situations before. Are there any good solutions? 

Thank you in advance for any suggestions and help
David

powershell ise result:
TIM was found at C:\Program Files\LibreAutomate
TIM was not found at C:\Program Files (x86)\LibreAutomate

PsCmd2 result:
TIM was not found at C:\Program Files (x86)\LibreAutomate
TIM was not found at C:\Program Files (x86)\LibreAutomate



Macro Macro10
Code:
Copy      Help
_s=
;$programFiles = [Environment]::GetFolderPath("ProgramFiles")
;$programFilesx86 = [Environment]::GetFolderPath("ProgramFilesX86")
;
;$searchPaths = @("$programFiles\LibreAutomate", "$programFilesx86\LibreAutomate")
;
;foreach ($searchPath in $searchPaths)
;{
;,if (Test-Path "$searchPath\Au.Editor.exe")
;,{
;,,write-output "TIM was found at $searchPath"
;,}
;,else
;,{
;,,write-output "TIM was not found at $searchPath"
;,}
;}
PsCmd2 _s "" _s
out _s
#2
I cannot confirm this (not at a pc). I suspect when you run poweshell from qm it runs in 32bit powershell where normally when run powershell directly it's run in 64 bit. Will test later when I'm near a pc.
#3
Code:
Copy      Help
__DisableFsRedirection dfr.Disable
#4
thank you so much!
QM solves problems so elegantly and is unparalleled.

How to solve it under LA?
#5
Quote:How to solve it under LA?
What do you mean?
#6
QM - creates problems and then elegantly solves them.
LA - does not create problems.
#7
thank you!
LA runs well
Code:
Copy      Help
string code1 = """
[console]::OutputEncoding = [System.Text.Encoding]::Unicode
$programFiles = [Environment]::GetFolderPath("ProgramFiles")
$programFilesx86 = [Environment]::GetFolderPath("ProgramFilesX86")

$searchPaths = @("$programFiles\LibreAutomate", "$programFilesx86\LibreAutomate")

foreach ($searchPath in $searchPaths)
{
    if (Test-Path "$searchPath\Au.Editor.exe")
    {
        write-output "TIM was found at $searchPath"
    }
    else
    {
        write-output "TIM was not found at $searchPath"
    }
}
"""
;
string file1 = folders.ThisAppTemp + "PowerShell.ps1";
filesystem.saveText(file1, code1, encoding: Encoding.Unicode);
run.console("PowerShell.exe", $"-ExecutionPolicy Bypass -File \"{file1}\"", encoding: Encoding.Unicode);


Forum Jump:


Users browsing this thread: 1 Guest(s)