ConfigMgr 2012: 64bit file system redirection bites again…
September 24, 2012 5 Comments
Even though the ConfigMgr 2012 client is supposedly 64bit now, the issue with 64bit file system redirection is still very much a problem during Task Sequence and even regular package/program deployments when we want to copy things to the ‘Native’ “%Program Files%” or “%WinDir%\System32”. File System redirection kicks in and we are magically transported to the 32bit “Program Files (x86)” or “Windows\SysWOW64”. Boo hiss. I even found a log entry in the client-side execmgr.log which clearly states;
Running "C:\Windows\ccmcache\3\CopyFiles-Temp.cmd" with 32bitLauncher
Why? Why? Why?
In the Task Sequence we can easily get around this problem by choosing to run a “Run Command Line” step instead of an Install Package step; we reference our package and command line and ensure we tick the box to “Disable 64bit file system redirection.” This is all well and good but what about deployments outside of the Task Sequence? There simply isn’t the same option, so we need to build this into our script/batch file that we are trying to run. My borderline Obsessive Compulsiveness dictates that the single solution must ‘just work’ for both 32bit and 64bit operating systems.
The most elegant way I have found for doing this that doesn’t involve re-writing sections of your batch file to cater for the various operating environments, involves taking advantage of being able to invoke the ‘Native’ 64bit command processor (system32\cmd.exe) from within any 32bit command processor running within a 64bit OS if needed. Here’s a snippet of code you simply add to the very top of your existing batch files…
@ECHO OFF IF NOT "%PROCESSOR_ARCHITEW6432%"=="AMD64" GOTO native ECHO "Re-launching Script in Native Command Processor..." %SystemRoot%\Sysnative\cmd.exe /c %0 %* EXIT :native ECHO "Running Script in Native Command Processor..." REM Your script starts here
What this will do for you, is first detect if the batch file is being ran from within a 32bit command interpreter on a 64bit OS – if it isn’t then the code jumps to the “:native” label and continues your script as usual. If we are in a 32bit command interpreter on a 64bit OS, then the script invokes the ‘Native’ 64bit command processor to run this very same batch file and then exit. The %PROCESSOR_ARCHITEW6432% condition near the top will simply be evaluated again by the Native command processor and ignored (as we are running 64bit cmd.exe in 64bit OS, or a 32bit cmd in a 32bit OS) and your script will happily continue without being subject to redirection. Neat!
Andy
Great post thanks
Mmm
tried to solve it today like you desribed it. But the Batch starts Looping.
If I do it manually from the command line like
start c:\Windows\syswow64\cmd.exe PROCESSOR_ARCHITEW6432 =AMD64
start c:\windows\system32\cmd.exe from inside the above cmd start PROCESSOR_ARCHITEW6432 ist still AMD64
Nothing changed. Any idea what’s going on here?
Thanks in advance
Joachim
Ok
solved it today. It’s simple just RTFM. I’ve never heard before about the “Sysnative” Alias so I replaced it with the 64Bit cmd which did not work. 🙂
Thanks
Pingback: SCCM 2012 Programs running as 32bit on 64bit OS | - danovich.com.au -
This wins the internet for me today – Thanks!