SCCM, batch files, and 32-bits processes on 64-bits OS

Today I was (again) confronted with the annoying System32-on64bit-OS situation.
To enable the Disk Cleanup Tool on Windows 2008 (R2), I had to copy 2 executables from the source location to C:\Windows\system32\*
I created a batch file, containing 2 lines:

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32\cleanmgr.exe
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui C:\Windows\System32\en-US\cleanmgr.exe.mui
Manually running the batch file on the server works fine: As long as I ran the batch elevated (as administrator), the files were copied to the target location. However, when executing the batch file from a package in SCCM, nothing happened. This issue is related to the fact that the SCCM client is a 32bits process running on a 64bits OS.

The solution is easy… Once you know it. 🙂
Use %systemroot%\sysnative\cmd.exe to execute the commands.
More information about Sysnative: http://www.samlogic.net/articles/sysnative-folder-64-bit-windows.htm
More information about cleanmgr: https://www.lisenet.com/2014/disk-cleanup-on-windows-server-2008-without-installing-desktop-experience/

I ended up creating a package in SCCM, referring to a batch file cleanmgr_W2008_R2.bat

%systemroot%\sysnative\cmd.exe /c copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32\cleanmgr.exe
%systemroot%\sysnative\cmd.exe /c copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui C:\Windows\System32\en-US\cleanmgr.exe.mui

Enable_Cleanmgr_SCCM

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x