Friday, March 18, 2016

Deploying Office 2016 (Not Click to Run) via GPO and Batch

So recently I was tasked with upgrading an entire department, and soon to be later the rest of the company from 2013 to 2016 Office Pro.  Following the old time SysAdmins mantra: Least amount of administrative overhead as possible I'm gonna push deploy it.

At first I was going to try MDT 2012, which was a no go.  I created a package but spent a day watching LiteTouch.vbs say it ran but nothing ever happening.  Since Im on a time crunch I dropped MDT like a hot potato.

Second was a product we used to deploy Java called PDQDeploy by Admin Arsenal. This app was the total bomb on pushing out Java to our entire org last month.  Worked like a champ!  However much like MDT I spent too much time troubleshooting why it was not working.  I created a package and a task sequence but it'd sit there until the timeout saying Step 1 was running but nothing ever happened.  Running the batch file manually worked though.

Next was GPO.  An old time favorite.  Although since there's no main MSI to cover the entire application you cannot Assign or Publish it via GPO but I discovered a batch file that was designed by MSFT for Office 2010 that with a few modifications, worked nicely for 2016.

setlocal

REM *********************************************************************
REM Environment customization begins here. Modify variables below.
REM *********************************************************************

REM Get ProductName from the Office product's core Setup.xml file, and then add "office16." as a prefix. 
set ProductName=Office16.PROPLUS

REM Set DeployServer to a network-accessible location containing the Office source files.
set DeployServer=\\netapp\mis\software\microsoft\office_2016\32

REM Set ConfigFile to the configuration file to be used for deployment (required)
set ConfigFile=\\netapp\mis\software\microsoft\office_2016\32\ProPlus.WW\config.xml

REM Set LogLocation to a central directory to collect log files.
set LogLocation=\\netapp\mis\software\microsoft\office_2016\LogFiles

REM *********************************************************************
REM Deployment code begins here. Do not modify anything below this line.
REM *********************************************************************

IF NOT "%ProgramFiles(x86)%"=="" (goto ARP64) else (goto ARP86)

REM Operating system is X64. Check for 32 bit Office in emulated Wow6432 uninstall key
:ARP64
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432NODE\Microsoft\Windows\CurrentVersion\Uninstall\%ProductName%
if NOT %errorlevel%==1 (goto End)

REM Check for 32 and 64 bit versions of Office 2010 in regular uninstall key.(Office 64bit would also appear here on a 64bit OS) 
:ARP86
reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%ProductName%
if %errorlevel%==1 (goto DeployOffice) else (goto End)

REM If 1 returned, the product was not found. Run setup here.
:DeployOffice
start /wait %DeployServer%\setup.exe /config %ConfigFile%
echo %date% %time% Setup ended with error code %errorlevel%. >> %LogLocation%\%computername%.txt

REM If 0 or other was returned, the product was found or another error occurred. Do nothing.
:End

Endlocal

Calling this batch as a logon script worked VERY well.  However how do I get it to use my custom MSP?

Resolution: Place teh .MSP file in the Updates folder. BOOM!

Installer runs, and due to my MSP the user cannot cancel or change the installation options at all.  Now since this is a Logon script it is called again later when they logon.. however since it writes that ProductName=OFFICE16.ProPlus to the registry.. then upon rerun checks for that entries existence and when found, does not call the installer.

Awesome.

No comments:

Post a Comment