ActiveXPosh and 64bit
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
ActiveXPosh and 64bit
It is a .NET assembly, so technically it should all be in place. I'll look into it.
Alex
Alex
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
ActiveXPosh and 64bit
I develop a 32-bit application for managing Exchange servers. It's supposed to run on the Exchange server, which means that the server OS is 64-bit. The Exchange Powershell Snapin (Microsoft.Exchange.Management.PowerShell.Admin) is only availible as a 64-bit version. Since the application is 32-bit, Windows run it with the Wow64 redirections.
Before I found the AciveXPosh component, I just ShellExecuted() the Powershell.exe and captured the output - primitive and slow, but it works. To be able to run the 64-bit Powershell.exe from a 32-bit application (and subsequentely load the Exchange PSSnapin), I had to call the Wow64DisableWow64FsRedirection() function (kernel32.dll). That disables the Wow redirection for the current thread, and my 32-bit application can see the 64-bit files and registry keys.
With the ActiveXPosh component, I notice that it is not 64-bit aware and since it loads powershell in a new thread, it fails to load the 64-bit components.
Scenario 1 - I do not run Wow64DisableWow64FsRedirection() before creating the ActiveXPosh.
Results in automation error 0x800700c1 - "%1 is not a valid Win32 application".
Scenario 2 - I run Wow64DisableWow64FsRedirection() before creating the ActiveXPosh.
Init() works and PowerShell commands are working. When I run "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin", Powershell returns the 32-bit-PS-trying-to-run-64-bit-snapin error:
"Add-PSSnapin : No Windows PowerShell Snap-ins are available for version 1."
It's easy enough to fix ActiveXPosh without rebuilding it as a 64-bit version. Just add the call to Wow64DisableWow64FsRedirection() before loading Powershell, and it should be fine. The function does nothing on a 32-bit OS, and should be harmless to just add.
What do you say?
Before I found the AciveXPosh component, I just ShellExecuted() the Powershell.exe and captured the output - primitive and slow, but it works. To be able to run the 64-bit Powershell.exe from a 32-bit application (and subsequentely load the Exchange PSSnapin), I had to call the Wow64DisableWow64FsRedirection() function (kernel32.dll). That disables the Wow redirection for the current thread, and my 32-bit application can see the 64-bit files and registry keys.
With the ActiveXPosh component, I notice that it is not 64-bit aware and since it loads powershell in a new thread, it fails to load the 64-bit components.
Scenario 1 - I do not run Wow64DisableWow64FsRedirection() before creating the ActiveXPosh.
Results in automation error 0x800700c1 - "%1 is not a valid Win32 application".
Scenario 2 - I run Wow64DisableWow64FsRedirection() before creating the ActiveXPosh.
Init() works and PowerShell commands are working. When I run "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin", Powershell returns the 32-bit-PS-trying-to-run-64-bit-snapin error:
"Add-PSSnapin : No Windows PowerShell Snap-ins are available for version 1."
It's easy enough to fix ActiveXPosh without rebuilding it as a 64-bit version. Just add the call to Wow64DisableWow64FsRedirection() before loading Powershell, and it should be fine. The function does nothing on a 32-bit OS, and should be harmless to just add.
What do you say?
- Ferdinand Rios
- Posts: 373
- Last visit: Fri Sep 16, 2022 1:24 pm
ActiveXPosh and 64bit
We will have our dev team take a look at this. If you are willing to work with them on testing, I am pretty certain that they will take a close look at it.
F.G. Rios
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
ActiveXPosh and 64bit
It's not that simple. We cannot just call Wow64DisableWow64FsRedirection and load 64 bit components.
You simply cannot mix 32 and 64 bit code.
While Wow64DisableWow64FsRedirection is only per thread it just enables you to find the files, it does not allow to load 64 bit components into a 32 bit process.
Alexander Riedel2009-04-03 09:57:38
You simply cannot mix 32 and 64 bit code.
While Wow64DisableWow64FsRedirection is only per thread it just enables you to find the files, it does not allow to load 64 bit components into a 32 bit process.
Alexander Riedel2009-04-03 09:57:38
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
ActiveXPosh and 64bit
I'm running What'sUp Gold on 2008 64-bit and it can run customized scripts via VBScript and I was consistently getting issues when trying to use ActiveXPoSH within my script (and I'd also installed the latest version). Turns out that when I ran CScript or WScript from the c:WINDOWSSYSWOW64 folder, it'd run without an issue. Therefore, I tested and found WUG to be running the 64 bit version of CSCRIPT/WSCRIPT out of the %windir%system32 folder, which in turn ran a different registry code-line.Here's how I correct this:I exported the following key:[HKEY_LOCAL_MACHINESOFTWAREClassesWow6432NodeCLSID{6E9C00CA-D11C-424C-A139-1F60F1930165}]and imported it into: [HKEY_LOCAL_MACHINESOFTWAREClassesCLSID{6E9C00CA-D11C-424C-A139-1F60F1930165}]and ActiveXPoSH works like a charm!!!
- anupamagarwal
- Posts: 8
- Last visit: Wed May 05, 2010 1:50 am
ActiveXPosh and 64bit
Hi Alexander,
Do you have a 64-bit version of ActivePOSH now? It would be very helpful to have one. Thanks!
Do you have a 64-bit version of ActivePOSH now? It would be very helpful to have one. Thanks!
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
ActiveXPosh and 64bit
It's a .net assembly, so it doesn't require a specific version. You should be able to register it for 64 bit systems without problem. Just run the 64 bit regasm.exe on it.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- anupamagarwal
- Posts: 8
- Last visit: Wed May 05, 2010 1:50 am
ActiveXPosh and 64bit
I am not familiar with regasm.exe. Can you please post more specif instructions for doing it? For example, where is regasm.exe located and what file do I run this for? If it is a DLL, where is the file located.
Thanks
Thanks