Steve Borba

My notes, I hope they help you, feel free to comment/add to them

Server 2016 Install

@Echo off
if not exist c:\Temp md C:\Temp

echo Disable netbios
wmic nicconfig where (TcpIpNetBiosOptions!=Null and TcpIpNetBiosOptions!=2) call setTcpIpNetBios 2

Echo Enable Remote Desktop
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f >nul

echo Remove Logon Background
reg add HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System /t REG_DWORD /v DisableLogonBackgroundImage /d 1 /f >nul
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0xFF /f >nul

Echo Remove Unwanted default packages, may take a few moments
Set RemoveThese=SMB1Protocol,Printing-Client,Printing-PrintToPDFServices-Features,Printing-XPSServices-Features
for %%a in (%RemoveThese%) do Dism /online /norestart /Disable-Feature /featurename:%%a >nul

Echo disable hibernate/hiberfill
powercfg -h off
Echo set countdown to 5 (default 30)
bcdedit /timeout 5

echo Update default User Profile
REG LOAD HKEY_USERS\default c:\Users\Default\NTUSER.DAT >nul

reg add "HKEY_USERS\default\Console" /v "QuickEdit" /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\Console" /v "ScreenBufferSize" /t reg_dword /d 655294544 /f >nul

reg add "HKEY_USERS\default\Software\Microsoft\Internet Explorer\Main" /v "StatusBarOther" /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Internet Explorer\Main" /v "DisableFirstRunCustomize" /t REG_DWORD /d "1" /f >nul

reg add "HKEY_USERS\default\Software\Microsoft\ServerManager" /v "DoNotOpenServerManagerAtLogon" /t reg_dword /d 1 /f >nul

reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer" /v EnableAutoTray /t reg_dword /d 0 /f >nul
rem reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "TaskbarSmallIcons" /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_ShowHelp" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_NotifyNewApps" /t reg_dword /d 0 /f >nul
rem reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Start_LargeMFUIcons" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Hidden" /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideDrivesWithNoMedia" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "ShowSuperHidden" /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "SharingWizardOn" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "AlwaysShowMenus" /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" /v "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" /t reg_dword /d 0 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}" /t reg_dword /d 0 /f >nul

reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v HideSCAHealth=dword /d 1 /f >nul
reg add "HKEY_USERS\default\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v Wallpaper /d "" /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Attachments" /v SaveZoneInformation /t reg_dword /d 2 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Attachments" /v ScanWithAntiVirus /t reg_dword /d 3 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDriveTypeAutoRun /t reg_dword /d 95 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoInplaceSharing /t reg_dword /d 1 /f >nul

reg add "HKEY_USERS\default\SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableThirdPartySuggestions /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop" /v SCRNSAVE.EXE /t reg_sz /d "scrnsave.scr" /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop" /v ScreenSaverIsSecure /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop" /v ScreenSaveActive /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop" /v ScreenSaveTimeOut /t reg_dword /d 600 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Pushnotifications" /v NoToastApplicationNotificationOnLockScreen /t reg_dword /d 1 /f >nul
reg add "HKEY_USERS\default\SOFTWARE\Policies\Microsoft\Windows\Installer" /v AlwaysInstallElevated /t reg_dword /d 0 /f >nul


REG UNLOAD HKEY_USERS\default >nul
echo Making Disk Changes

echo rescan>"%temp%\diskpart.txt"
echo select Volume c>>"%temp%\diskpart.txt"
echo extend>>"%temp%\diskpart.txt"
echo exit>>"%temp%\diskpart.txt"
diskpart /s "%temp%\diskpart.txt" > nul

Rem Check for other disks with space, move DVD, format, mount, change permissions
echo list disk>"%temp%\diskpart.txt"
echo exit>>"%temp%\diskpart.txt"
diskpart /s "%temp%\diskpart.txt" > "%temp%\disklist.txt"

type "%temp%\disklist.txt" | find /v "0 B" | find /i "Disk 1" > nul
if not %errorlevel% == 0 goto skip-d

Echo Move CD to D
echo select volume D>"%temp%\diskpart.txt"
echo Remove>>"%temp%\diskpart.txt"
echo Assign letter E>>"%temp%\diskpart.txt"
echo exit>>"%temp%\diskpart.txt"
diskpart /s "%temp%\diskpart.txt"

Echo Format and mount D
echo select disk 1>"%temp%\diskpart.txt"
echo online disk>>"%temp%\diskpart.txt"
echo ATTRIBUTES DISK CLEAR READONLY>>"%temp%\diskpart.txt"
echo CREATE PARTITION PRIMARY>>"%temp%\diskpart.txt"
echo FORMAT LABEL="Data" QUICK>>"%temp%\diskpart.txt"
echo assign letter=D>>"%temp%\diskpart.txt"
echo exit>>"%temp%\diskpart.txt"
diskpart /s "%temp%\diskpart.txt"

icacls d: /T /remove Everyone
icacls d: /T /remove BUILTIN\Users
icacls d: /T /remove "CREATOR OWNER"
icacls d: /grant "NT AUTHORITY\INTERACTIVE:(RX)"
:skip-d

echo Installing windows updates
PowerShell -Command "Set-ExecutionPolicy bypass"
powershell -file WindowsUpdates.ps1 -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile
dism /online /cleanup-image /StartComponentCleanup /resetbase
Echo Store Version in Ver
for /f "Tokens=*" %%a in ('ver') do if not "%%a" == "" set Ver=%%a

PowerShell -Command "(Get-CimInstance -ClassName SoftwareLicensingProduct | where {$_.PartialProductKey -and $_.Name -like '*Windows*'}).LicenseStatus" > %temp%\lic.txt
for /f %%a in (%temp%\lic.txt) do set LicenseStatus=%%a
if "%LicenseStatus%" == "1" goto SkipActivateWindows

Echo Activating Windows...
Set ActivationKey=None
if "%Ver%" == "Microsoft Windows [Version 6.1.7601]" Set ActivationKey=YC6KT-GKW9T-YTKYR-T4X34-R7VHC
rem 489J6-VHDMP-X63PK-3K798-CPX3Y 74YFP-3QFB3-KQT8W-PMXWJ-7M648
if "%Ver%" == "Microsoft Windows [Version 6.2.9200]" Set ActivationKey=XC9B7-NBPP2-83J2H-RHMBY-92BT4
rem 48HP8-DN98B-MYWDG-T2DCC-8W83P
if "%Ver%" == "Microsoft Windows [Version 6.3.9600]" Set ActivationKey=D2N9P-3P6X9-2R39C-7RTCD-MDVJX
if "%Ver%" == "Microsoft Windows [Version 10.0.14393]" Set ActivationKey=WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY
rem Server 2016 data center is CB7KF-BWN84-R7R2Y-793K2-8XDDG
If not %ActivationKey% == None cscript //B C:\Windows\System32\slmgr.vbs /ipk %ActivationKey%
cscript //B C:\Windows\System32\slmgr.vbs /ato
:SkipActivateWindows

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>