/build/static/layout/Breadcrumb_cap_w.png

SCCM Pre-install Check Batch Script

Recently I was presented with an issue, and it was deploying multiple applications via sccm in a sequence, however the client did not want to make use of task sequences, and wanted the install to check for pre-existing applications and install if any were missing and that any errors during the install to be sent back to SCCM.

The Batch Script

@ECHO OFF
set regpath=HKLM\<Registry Path>
set regvalue=<Key>
set regdata= <Value>
reg query %regpath% /v %regvalue% | find /i %regdata%
if not error level 1 go to end
:not_found
echo Please wait while <Application name> is installed
<app install command line>
if not %errorlevel%"=="0" exit /30066
:end

if the install fails it will exit the batch file error code 30066

Examples

Microsoft .Net Framework 2.0

@ECHO OFF
set regpath=HKLM\SOFTWARE\MICROSOFT\NET FRAMEWORK SETUP\NDP\V2.0.5727
set regvalue=install
set regdata=1
reg query %regpath% /v %regvalue% | find /i %regdata%
if not error level 1 go to end
:not_found
echo Please wait while .net 2.0 is installed
dotnetfx.exe /q:a /c:"install /I /Q"
if not %errorlevel%"=="0" exit /30066
:end


Comments

  • why not use wmic product get name,version ? - dedenker 6 years ago
  • Why cant use detection registry method in sccm directly? - apptopack 5 years ago
This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ