How to determine if an EXE is 16bit, 32bit (x86), or 64bit (x64)...

break on
$RC=setoption("NoVarsInStrings","on")
$RC=setoption("NoMacrosInStrings","on")
$RC=setoption("WrapATEOL","on")
 
? PSGetBinaryType('%systemroot%\notepad.exe')
? PSGetBinaryType(@scriptdir + '\kix32.exe')
 
function PSGetBinaryType($FQFN, optional $PSObject) dim $result,$values[7] $values="Windows 32bit","MSDOS","Windows 16bit","PIF","POSIX","OS/2 16bit","Windows 64bit" if $PSobject="" $PSObject=CreateObject("SAPIEN.ActiveXPoSH") endif if exist($FQFN) if $PSObject.init(not 0) $PSGetBinaryType=-1 $PSObject.Execute("$sig='" + '[DllImport("kernel32.dll")]' + @CRLF + 'public static extern bool GetBinaryType(string lpApplicationName,ref int lpBinaryType);' + "'") $PSObject.Execute('$GetBinaryType=Add-Type -memberDefinition $sig -namespace Win32Functions -name "BinaryType" -passThru') $PSObject.Execute('$ReturnedType = -1') $Result=$PSObject.GetValue('$GetBinaryType::GetBinaryType("' + $FQFN + '",[ref] $ReturnedType)') if $result="True" $PSGetBinaryType=$values[$PSObject.Getvalue('$ReturnedType')] endif endif endif endfunction