tag:blogger.com,1999:blog-10074565.post1355352042662621565..comments2023-06-04T07:34:10.152+00:00Comments on cornasdf's field: Force a powershell script to run in x86 process with argumentscornasdfhttp://www.blogger.com/profile/02328281836126704285noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-10074565.post-84738699180449718592012-10-29T14:37:35.952+00:002012-10-29T14:37:35.952+00:00hello i try to run my old system clipper that only...hello i try to run my old system clipper that only execute on x86 win7 but this err appear on poweshell x86 in windows7 64<br /><br />PS Z:\> .\EXAMEN.EXE<br />Error al ejecutar el programa 'EXAMEN.EXE': Unknown error (0xd8)<br />En línea: 1 Carácter: 13<br />+ .\EXAMEN.EXE <<<< .<br />En línea: 1 Carácter: 1<br />+ <<<< .\EXAMEN.EXE<br /> + CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException<br /> + FullyQualifiedErrorId : NativeCommandFailed<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-10074565.post-69408126699338172772012-01-05T19:25:22.574+00:002012-01-05T19:25:22.574+00:00I forgot. If you want it vice versa:
That means ru...I forgot. If you want it vice versa:<br />That means running 64bit powershell from 32bit powershell:<br /><br />if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {<br /> write-warning "Running AMD64 PowerShell..."<br /> if ($myInvocation.Line) {<br /> &"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $myInvocation.Line<br /> } else {<br /> &"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args<br /> }<br /> <br /> exit $lastexitcode<br />}<br /><br />Regards,<br />Grischa ZengelAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-10074565.post-8943243270036350392012-01-05T19:18:34.574+00:002012-01-05T19:18:34.574+00:00This one is more flexible:
if ($env:Processor_Arc...This one is more flexible:<br /><br />if ($env:Processor_Architecture -ne "x86") {<br /> write-warning "Running x86 PowerShell..."<br /> if ($myInvocation.Line) {<br /> &"$env:WINDIR\syswow64\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $myInvocation.Line<br /> } else {<br /> &"$env:WINDIR\syswow64\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args<br /> }<br /> <br /> exit $lastexitcode<br />}<br /><br />Regards,<br />Grischa ZengelAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-10074565.post-23091357291082421572011-02-04T17:56:27.064+00:002011-02-04T17:56:27.064+00:00That's a good point, I should have mentioned y...That's a good point, I should have mentioned you can do it as part of the command, depending on your security requirements. I generally set it to 'RemoteSigned' myself. YMMV.cornasdfhttps://www.blogger.com/profile/02328281836126704285noreply@blogger.comtag:blogger.com,1999:blog-10074565.post-1896131872045125282011-02-04T14:49:40.929+00:002011-02-04T14:49:40.929+00:00if you run PowerShell /? you will find that the ex...if you run PowerShell /? you will find that the executionpolicy switch is there, you just can't use "bypass" in v2. Use "-ExecutionPolicy Unrestricted" and you shouldn't have to worry about the 32-bit execution policy.Anonymousnoreply@blogger.com