@ECHO OFF :: Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:: If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( Echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin )
:gotAdmin if exist "%temp%\getadmin.vbs" ( Del "%temp%\getadmin.vbs" ) Pushd "%CD%" CD /D "%~dp0" :--------------------------------------
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION SET ERRORLEVEL= SET ERRNUM= FOR /R "%~dp0" %%A IN (*-KB*.MSU) DO ( CALL :SUB %%~nA ECHO= Installing KB!KB_NUM! >NUL TIMEOUT /t 3 SET ERRORLEVEL= WUSA "%%A" /quiet /norestart SET ERRNUM=!ERRORLEVEL! IF !ERRNUM! EQU 3010 ( ECHO= == SUCCESS ^(RebootRequired^) ^[!ERRNUM!^] == ) ELSE ( IF ERRORLEVEL 1 ( ECHO= == FAILED ^[!ERRNUM!^] == ) ELSE ( ECHO= == SUCCESS ^[!ERRNUM!^] == ) ) ) CHOICE /C YN /M "Close all programs and press Y to restart or N to continue." IF ERRORLEVEL 2 GOTO continue IF ERRORLEVEL 1 GOTO restart GOTO end :continue GOTO end :restart ECHO= == Press any key to restart == >NUL PAUSE SHUTDOWN.EXE /r /t 0 :end GOTO :EOF
:SUB SET "KB_NUM=%*" FOR /F "DELIMS=-" %%B IN ("%KB_NUM:*-KB=%") DO SET "KB_NUM=%%B"
REM http://www.msfn.org/board/topic/152020-batch-script-for-windows-software-updates-installation/page__view__findpost__p__964942 REM http://www.windows-commandline.com/2011/10/choice-command.html REM http://blogs.msdn.com/b/oldnewthing/archive/2008/09/26/8965755.aspx REM http://ss64.com/nt/delayedexpansion.html REM http://ss64.com/nt/runas.html
devam=MsgBox(myprompt,mybuttons,mytitle) If (devam = 2) or (devam = 3) or (devam = 7) Then 'Cancel/Abort/No was clicked wscript.quit(1) End If
End If
Next
If (something = 0) Then MsgBox "Nothing to do.",64,mytitle Else MsgBox "Done.",64,mytitle restartla=MsgBox("Close all programs and press Yes to restart or No to continue.",36,mytitle) If (restartla = 6) Then Set WSHShell = WScript.CreateObject("WScript.Shell") WshShell.Run "%SYSTEMROOT%\system32\shutdown.exe /r /t 0" End If End If
Batch script for windows & software updates installation
in Unattended Windows 7/Server 2008R2
Posted
+++++++
+ VBScript Alternative
+++++++
InstallMSU.zip