Scripts, Windows

InstallWDS – Installing Windows Deployment Services (WDS) from a batch file

Written in 2009 for the Windows versions of the time. Check that the tool or steps still suit your environment before using them.

Prerequisites

  • WDS and service pack files on a share
  • Windows Server 2003 or 2008
  • Administrator rights (writes to HKLM)

Installing Windows Deployment Services (WDS) from a batch file

I needed to install WDS on 300+ servers but found that the server build did not have a local copy of OS setup or service pack files. I also wanted to set the paths back to the original values.

I started by adding all files required by WDS to the DFS and I created the following batch file.

@ECHO OFF

REG EXPORT "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" %WINDIR%\InstallWDS.reg /y
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v "SourcePath" /t REG_SZ /d "\\SERVERNAME\SHARE" /f
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup" /v "ServicePackSourcePath" /t REG_SZ /d "\\SERVERNAME\SHARE" /f

VER | Find "Microsoft Windows [Version 5.2." > nul
If %ERRORLEVEL% == 0 GoTo Win2003
VER | Find "Microsoft Windows [Version 6.0." > nul
If %ERRORLEVEL% == 0 GoTo Win2008

GoTo CleanUp

:Win2003
ECHO [Components] > %WINDIR%\InstallWDS.inf
ECHO RemInst = on >> %WINDIR%\InstallWDS.inf
Sysocmgr.exe /i:sysoc.inf /u:%WINDIR%\InstallWDS.inf
GoTo CleanUp

:Win2008
ServerManagerCmd -install WDS
GoTo CleanUp

:CleanUp
REG IMPORT %WINDIR%\InstallWDS.reg
DEL %WINDIR%\InstallWDS.inf
DEL %WINDIR%\InstallWDS.reg

Publishers website: https://www.ittelligence.com
ITtelligence mirror: InstallWDS.zip (480 B)

How to Use ItLink to this section

It takes no parameters. Replace both \\SERVERNAME\SHARE placeholders with the share that holds the setup and service pack files, then run it as an administrator on the server.

InstallWDS.bat

It backs up HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup, points SourcePath and ServicePackSourcePath at the share, and installs WDS. When VER reports version 5.2 it runs Sysocmgr.exe with RemInst = on; when it reports 6.0 it runs ServerManagerCmd -install WDS. It then imports the backup to restore the original paths. On any other version it only restores the registry. There is no output of its own beyond what the installers show.

Posted on

No comments yet

Comments are moderated and appear once approved.