<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx</link><description>In an ideal world, everything runs as native bitness (64bit program on 64bit OS, 32bit program on 32bit OS) and life goes on. However, sometimes you need to run that legacy 32bit program on a 64bit OS and need to configure things a little differently</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#10327817</link><pubDate>Sun, 08 Jul 2012 16:11:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10327817</guid><dc:creator>alex.my</dc:creator><description>&lt;p&gt;Thank you very much, that help me a lot.&lt;/p&gt;
&lt;p&gt;How I need a batch script and don&amp;#39;t know how use AND, OR I needed make some changes, here works fine, please take a look and tell me if exist some wrong.&lt;/p&gt;
&lt;p&gt;@ECHO OFF&lt;/p&gt;
&lt;p&gt;IF /I %PROCESSOR_ARCHITECTURE% == x86 GOTO x86&lt;/p&gt;
&lt;p&gt;ECHO your 64bit Native code here ...&lt;/p&gt;
&lt;p&gt;GOTO END&lt;/p&gt;
&lt;p&gt;:AMD64&lt;/p&gt;
&lt;p&gt;ECHO your WOW64 code here ...&lt;/p&gt;
&lt;p&gt;GOTO END&lt;/p&gt;
&lt;p&gt;:x86&lt;/p&gt;
&lt;p&gt;IF DEFINED PROCESSOR_ARCHITEW6432 GOTO AMD64&lt;/p&gt;
&lt;p&gt;ECHO your 32bit Native code here ...&lt;/p&gt;
&lt;p&gt;:END&lt;/p&gt;
&lt;p&gt;pause&lt;/p&gt;
&lt;p&gt;---------------------------------------------------------------------------------&lt;/p&gt;
&lt;p&gt;If in your application amd64 = wow64 is fine you can more simple:&lt;/p&gt;
&lt;p&gt;@ECHO OFF&lt;/p&gt;
&lt;p&gt;IF /I %PROCESSOR_ARCHITECTURE% == x86 GOTO x86&lt;/p&gt;
&lt;p&gt;:AMD64&lt;/p&gt;
&lt;p&gt;ECHO your 64bit Native and WOW64 code here ...&lt;/p&gt;
&lt;p&gt;GOTO END&lt;/p&gt;
&lt;p&gt;:x86&lt;/p&gt;
&lt;p&gt;IF DEFINED PROCESSOR_ARCHITEW6432 GOTO AMD64&lt;/p&gt;
&lt;p&gt;ECHO your 32bit Native code here ...&lt;/p&gt;
&lt;p&gt;:END&lt;/p&gt;
&lt;p&gt;pause&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10327817" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#10271535</link><pubDate>Thu, 23 Feb 2012 17:10:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10271535</guid><dc:creator>Darr247</dc:creator><description>&lt;p&gt;Robert 9 Jan 2010:&lt;/p&gt;
&lt;p&gt;&amp;gt; or alternatively HKLM\Software\WOW6432Node branch exist&lt;/p&gt;
&lt;p&gt;Not good. That key CAN exist on 32-bit Windows, as a symbolic link to the 32-bit hive.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms724072(v=vs.85).aspx"&gt;msdn.microsoft.com/.../ms724072(v=vs.85).aspx&lt;/a&gt;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10271535" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#10232017</link><pubDate>Tue, 01 Nov 2011 10:20:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10232017</guid><dc:creator>Neelima Rustagi</dc:creator><description>&lt;p&gt;David,&lt;/p&gt;
&lt;p&gt;thanks for the valuable post.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10232017" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#9946104</link><pubDate>Sat, 09 Jan 2010 14:09:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9946104</guid><dc:creator>Robert</dc:creator><description>&lt;p&gt;I believe that the only reliable way to tell x86 and AMD64 apart is to check whether %SystemRoot%\SysWOW64 folder or alternatively HKLM\Software\WOW6432Node branch exist.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9946104" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#9946101</link><pubDate>Sat, 09 Jan 2010 14:02:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9946101</guid><dc:creator>Robert</dc:creator><description>&lt;p&gt;Unfortunately this doesn't work correctly when 64-bit cmd.exe is executed inside a 32-bit process (e.g. Total Commander does this). This is because environment of a 32-bit program is passed to a 64-bit child process and the detected architecture is x64 running in WOW64 mode. This may cause a lot of confusion. For example, %SystemRoot%\Sysnative is not a valid path for 64-bit processes, while it is the only way to reach actual %SystemRoot%\System32 on an x64 in WOW64.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9946101" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#9427414</link><pubDate>Tue, 17 Feb 2009 13:58:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9427414</guid><dc:creator>David.Wang</dc:creator><description>&lt;p&gt;Jeff - &amp;nbsp;All of the redirections on 64bit Windows are actually very rational once you understand what it is doing and work with it instead of against it. It only feels frustrating until you know what you are truly doing.&lt;/p&gt;
&lt;p&gt;The core of your problem is that your batch file is launched by a 32bit command interpreter on 64bit OS which causes you to go down the WOW path when you want to go down the native 64bit path. You have to figure out what is wrong with your unattend install command which kicks it off.&lt;/p&gt;
&lt;p&gt;I do lots of OS automation/unattend installation using both CScript and Batch files, and they always kick off with the bitness I intend, so your unintended 32bitness issue is most definitely specific with what you are doing. I don't know what exactly you mean by &amp;quot;running in batch as part of the unattend install&amp;quot;. Is this from the GUIRunOnce or something else?&lt;/p&gt;
&lt;p&gt;//David&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9427414" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#9391201</link><pubDate>Mon, 02 Feb 2009 22:17:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9391201</guid><dc:creator>Jeff</dc:creator><description>&lt;p&gt;Can the PROCESSOR_ARCHITEW6432 environment variable be queried from a batch script? &amp;nbsp;If so, how?&lt;/p&gt;
&lt;p&gt;I have an unattended O/S install DVD that I use to install both 32bit and 64bit Windows 2003 servers. &amp;nbsp;The DVD contains both 32bit and 64bit versions of applications like the HP hardware drivers, our antivirus software, etc...&lt;/p&gt;
&lt;p&gt;My batch file looks like this: &lt;/p&gt;
&lt;p&gt;&amp;lt;snip&amp;gt;&lt;/p&gt;
&lt;p&gt;echo %processor_architecture &amp;gt;&amp;gt; C:\temp\install.log&lt;/p&gt;
&lt;p&gt;if /i %processor_architecture%==x86 GOTO x86&lt;/p&gt;
&lt;p&gt;if /i %processor_architecture%==EM64T GOTO x64&lt;/p&gt;
&lt;p&gt;if /i %processor_architecture%==AMD64 GOTO x64&lt;/p&gt;
&lt;p&gt;:x86&lt;/p&gt;
&lt;p&gt;...Run the x86 installer&lt;/p&gt;
&lt;p&gt;GOTO END&lt;/p&gt;
&lt;p&gt;:x64&lt;/p&gt;
&lt;p&gt;....Run the x64 installer&lt;/p&gt;
&lt;p&gt;:END&lt;/p&gt;
&lt;p&gt;&amp;lt;snip&amp;gt;&lt;/p&gt;
&lt;p&gt;If I run the batch script from a command prompt on a 64bit system, this works, but when running in batch as part of the unattended install, the command processor seems to be perpetually stuck in WOW mode as it consistently reports x86 as the value for %processor_architecture% even when running on a 64bit O/S.&lt;/p&gt;
&lt;p&gt;I need to resolve this as the registry redirection is driving me nuts when trying to update registry keys (like removing the autoadminlogon) and having it redirected to the Wow6432Node subkey where it has no effect.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9391201" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#8968276</link><pubDate>Mon, 29 Sep 2008 02:40:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8968276</guid><dc:creator>David.Wang</dc:creator><description>&lt;p&gt;Udi - I am pointing out the classic problems that people miss.&lt;/p&gt;
&lt;p&gt;You will have to provide your own answer because it depends on what you want to do.&lt;/p&gt;
&lt;p&gt;I am just saying that the problem exists only if you have one installer that tries to figure things out. If you have one 32bit and one 64bit installer, it is a non-issue.&lt;/p&gt;
&lt;p&gt;If you cannot come up with your own answer then you should stick with separate 32bit and 64bit installers. MSI-based installers easily detect bitness and do the right things, so trying to bake it all into one installer means you have to know what you are doing.&lt;/p&gt;
&lt;p&gt;I just think it is weird for a 32bit SYSWOW process to install 64bit code because it breaks compatibility.&lt;/p&gt;
&lt;p&gt;//David&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8968276" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#8968042</link><pubDate>Sun, 28 Sep 2008 17:29:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8968042</guid><dc:creator>Udi</dc:creator><description>&lt;p&gt;I understand, but when the process should be done automatically - what can you do?&lt;/p&gt;
&lt;p&gt;Indeed we have two different installation files and one that consists them both which tries to figure out which one to launch according to this key. The user should not be involved in the process.&lt;/p&gt;
&lt;p&gt;Please let me know in case I missed anything, and if you have an answer to the questions above I'll appreciate it :)&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Udi.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8968042" width="1" height="1"&gt;</description></item><item><title>re: HOWTO: Detect Process Bitness</title><link>http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx#8964857</link><pubDate>Thu, 25 Sep 2008 13:42:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8964857</guid><dc:creator>David.Wang</dc:creator><description>&lt;p&gt;Udi - I recommend against writing one installer that installs different bitness on the fly. It makes handling bitness more complicated than it needs to be. Just make a 32bit x86 installer and a 64bit x64 installer.&lt;/p&gt;
&lt;p&gt;For example, if I launch your installer on a 64bit OS while under a WOW64 cmd-shell, should your installer install 32bit, 64bit, both, or neither? And what is the user intention in this scenario? This will remain the classic problem on 64bit OS for many years to come.&lt;/p&gt;
&lt;p&gt;The answer is trivial with pure 32bit and pure 64bit installer. When you start adding logic, it can backfire.&lt;/p&gt;
&lt;p&gt;//David&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8964857" width="1" height="1"&gt;</description></item></channel></rss>