Skip to content

Instantly share code, notes, and snippets.

@shiitake
Created September 30, 2015 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiitake/48b35f6defc2209f2129 to your computer and use it in GitHub Desktop.
Save shiitake/48b35f6defc2209f2129 to your computer and use it in GitHub Desktop.
This is a batch script that you can use to prepare for a SQL Server installation/update/upgrade. See: http://bit.ly/1Lkjvh3
Echo cleaning out temp locations and old SQL Server setup logs
if exist "%temp%" del /Q /F "%temp%"
if exist "%SystemRoot%\temp" del /Q /F "%SystemRoot%\temp"
del /Q /F "%SystemRoot%\sql*.log"
del /Q /F "%SystemRoot%\*.iss"
if exist "“%SystemRoot%\sql.mif"
del /Q /F "%SystemRoot%\sql.mif"
if exist "%TEMP%\1" rmdir /S /Q "%TEMP%\1"
if exist "%TEMP%\2" rmdir /S /Q "%TEMP%\2"
if exist "%ProgramFiles%\Microsoft SQL Server\90\Setup Bootstrap\Log"
del /S /Q /F "%ProgramFiles%\Microsoft SQL Server\90\Setup Bootstrap\Log"
if exist "%ProgramFiles%\Microsoft SQL Server\100\Setup Bootstrap\Log"
del /S /Q /F "%ProgramFiles%\Microsoft SQL Server\100\Setup Bootstrap\Log"
if exist "%ProgramFiles%\Microsoft SQL Server\110\Setup Bootstrap\Log"
del /S /Q /F "%ProgramFiles%\Microsoft SQL Server\110\Setup Bootstrap\Log"
if exist "%ProgramFiles%\Microsoft SQL Server\120\Setup Bootstrap\Log"
del /S /Q /F "%ProgramFiles%\Microsoft SQL Server\120\Setup Bootstrap\Log"
Echo Clear and refresh name caches
ipconfig /flushdns nbtstat -R
ipconfig /registerdns nbtstat -RR
Echo Syncing time with domain controller
net time %logonserver% /SET /Y
Echo Replacing any missing default administrative shares (for 2k and 2k5). Repeat the last line through the entire alphabet for the drive letters: C, D, . . . Z.
net share ADMIN$
net share IPC$
if exist net share C$=C:\
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment