It's an old topic, but hey, so am I 🙂
We use the Domain Shutdown script to install all kinds of updates. The Shutdown script is, as the name implies, executed if you shut down your Windows (domain) computer. It's a simple .cmd script, so it's a bit 'how you do it'. With Powershell, it's probably much easier / powerful, I guess, but I don't master Powershell.
Edit: The Shutdown script is executed under the System account, which has permission to install stuff.
Let's have a look at the part installing Revit updates. I made a sub-routine that is CALLed to check the build number of the currently installed Revit version:
:versieno
rem Routine with max. 3 arguments:
rem 1 - path + filename
rem 2 - build number - used below as 'regular expression' to get an exact search result.
rem 3 - if not empty AND build number is incorrect, send a message.
rem Build number can be found in the release notes or by executing the command below:
rem wmic datafile where name='<path_to_executable>\<name_of_executable>' get version /format:list
if (%1)==() EXIT /B
set update=0
set temppath=%1
if not exist %temppath:\\=\% goto path_error
wmic datafile where name=%1 get version | findstr /R "\<%2\>" >nul
if not (%errorlevel%)==(0) set update=1
if not %update%==0 (if not [%3]==[] (call "%capps%Scripts\e-mail.cmd" "Problem with Revit update %computername%" %3 "")) >nul
set temppath=
EXIT /B
:path_error
set temppath=%~1
call "%capps%Scripts\e-mail.cmd" "Problem with Revit update %computername%" "Cannot find the path specified: %temppath:\\=\%" ""
set temppath=
EXIT /B
If there's a problem, it calls another script, sending an e-mail to me.
Now the part for installing, for example, Revit 2021 update 1.
rem = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
rem = = = =
rem = = Revit 2021 = =
rem = = = =
rem = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
echo:
echo ---------------------------------------------------------------
echo Revit 2021
rem Paths for updates
set source_path=<path_to_deployment>Autodesk\2021\Revit\Updates\
set target_path=c:\program files\Autodesk\Revit 2021\
set programm=Revit.exe
if not exist "%source_path%*.*" goto Revit_2021_end
if not exist "%target_path%*.*" goto Revit_2021_end
:Revit_2021_Update_01
rem Check if the build number is correct. If not, perform update.
rem If after installing the update, the build number is still incorrect, send a message.
set build_number="21.1.40.95"
call :versieno "%target_path:\=\\%%programm%" %build_number%
if not %update%==1 goto Revit_2021_Update_02
echo Install Update 1.4...
Start "" /B /wait "%source_path%Revit_2021_1_4.exe" /passive
call :versieno "%target_path:\=\\%%programm%" %build_number% "Problem with Revit 2021 update 1.4 - build number %versie:"=% incorrect."
:Revit_2021_Update_02
rem Some more stuff to install
:Revit_2021_end
It's rather simple. You have to specify the preferred build number, which is then compared with the build number of the installed program. If they differ, install the update. And if the still differ after the update is installed, send a message. If the build number is already up-to-date, skip to the end of the section.
Some weird stuff is needed to strip / add double backslashes: \=\\