I ran into a little problem while with trying to install an application inside of my Microsoft Deployment Toolkit 2010 distribution share. I needed a batch file, or script, to detect the hardware model of the computer first, then run the install. If the detection didn’t match the hardware model, then exit the script. After a few hours of research and testing, here is a little administrative script that I came up with. Here is what it does (in order):

  1. Detect the hardware model of the computer. If the MODEL matches a specific type then go to the next step. If not, exit.

  2. Check for a file name on the network (such as the name of a file of a text file or EXE). If the file exists, continue to the next step. If not, go to the next line in the script.

  3. Check for a file name on a local CD or DVD drive. If the file exists, continue to the next step. If not, exit.

  4. Copy the application folder to c:\install

  5. Run setup.

  6. Delete the C:\install folder.

  7. Script done.

** I added the network and CD\DVD checks in the script because we have both a network distribution share and a MEDIA disc that deploys Windows from a bootable DVD. So, not only do we deploy Windows from the MDT share on our network, we ship out bootable DVDs to branch sites for re-imaging computers at remote locations. This script fixes any type of install problems that may arise when performing installation instructions for a custom application.

SCRIPT SAMPLE:
@ECHO OFF
for /F "delims=" %%j in ('wmic csproduct get name') do set MODEL=%%j
If "%MODEL%" == "Latitude E6400  " GOTO CHECK1
GOTO GOODBYE

_:CHECK1
IF EXIST _
\SERVER\SHARE*__**APPLICATION*SETUP.EXE GOTO NETINSTALL
IF EXIST D:\FOLDER\SETUP.EXE GOTO CDINSTALLD
GOTO GOODBYE**

**:NETINSTALL
mkdir c:\install
xcopy \SERVER\SHARE**__APPLICATION C:\install
C:\INSTALL\SETUP.EXE /SILENT
rd c:\install /s /q
EXIT

:CDINSTALLD
mkdir c:\install
xcopy D:\FOLDER\SETUP.EXE C:\install
C:\install\setup.exe /S /noreboot
rd c:\install /s /q
EXIT

:GOODBYE
EXIT