[Solved] session-setup still launches powershell in 32bits

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
swbsf
Messages: 8
Registration: July 27, 2017 - 09:50

August 4, 2017 - 10:57

Good morning,
I admit it's quite convoluted, so I'm turning to you to see if anyone has any insights :)

My PowerShell script:

Code: Select all

$ErrorActionPreference="SilentlyContinue"
Stop-Transcript | out-null
$ErrorActionPreference="Continue"
Start-Transcript -path c:\tmp\Win10.log -append

if ([Environment]::Is64BitProcess) {
        echo "64 bit powershell" }
Else { echo "32 bit powershell" }
Stop-Transcript
The end of session-setup :

Code: Select all

        cmd="c:\\Windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File c:\\tmp\\Win10.ps1"
        run(cmd,timeout=7200)
And the logs tell me:

Code: Select all


    **********************
    Début de la transcription Windows Powershell
    Heure de début : 20170804094010
    Nom d'utilisateur : DESKTOP-IJCDS8M\bobby
    Utilisateur runAs : DESKTOP-IJCDS8M\bobby
    Ordinateur : DESKTOP-IJCDS8M (Microsoft Windows NT 10.0.15063.0)
    Application hôte : c:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File c:\tmp\Win10.ps1
    ID de processus : 3080
    PSVersion: 5.1.15063.502
    PSEdition: Desktop
    PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.15063.502
    BuildVersion: 10.0.15063.502
    CLRVersion: 4.0.30319.42000
    WSManStackVersion: 3.0
    PSRemotingProtocolVersion: 2.3
    SerializationVersion: 1.1.0.1
    **********************
    Transcription démarrée, le fichier de sortie est c:\tmp\Win10.log
    32 bit powershell
Amazing, isn't it? The application name, with the full path, is correct, and yet it launches the 32-bit version. But the 32-bit version doesn't have half the commands I need. Thanks, Microsoft.
Last edited by swbsf on August 4, 2017 - 11:20, edited 1 time.
swbsf
Messages: 8
Registration: July 27, 2017 - 09:50

August 4, 2017 - 11:02

The noose is tightening!

Code: Select all

    >>> run(u'c:\\Windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe -Command "[Environment]::Is64BitProcess"')
    <RunOuput returncode :0>
    u'False\r\n'
swbsf
Messages: 8
Registration: July 27, 2017 - 09:50

August 4, 2017 - 11:20

Okay, so I'll do the questions and answers. ;)
The answer was found here: https://stackoverflow.com/a/23395020/3829020
Sneaky little Windows!
To make a long story short, if you look for the process in System32, this directory is virtualized for 32-bit processes (in this case, Python), so you always end up with a 32-bit PowerShell. Therefore, you have to look for it in %SystemRoot%\SysNative.
Phew.
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

August 4, 2017 - 4:07 PM

Excellent solution!

We had the same problem when trying to call dism.exe on a package; you need to look at the Sysnative alias to make sure you're calling the correct one.

Alexandre
Locked