IAN-XEU, I ran the script several times with no issue, but today I was prompted with that box,
"There are updates available. Click OK to start upgrade."
Is there a way to bypass that? The automation breaks until someone answers YES.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I just don't know the syntax to make this end. It does its job; it takes Office from 1705 to 2008 by version #, but once it does, it continues an endless loop of "Checking for Updates."
Also, after the first run through, a popup comes up saying Office has been Upgraded.
It requires clicking OK for the 2nd run through to begin. I'm wondering how to avoid that as well if possible.
$UpdateEXE ="C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe"
2. $UpdateArguements = "/update user displaylevel=true"
3. $updatetoversion="16.0.etc"
4. $version = Get-WmiObject win32_product | where{$_.Name -like "Microsoft Office Professional Plus*"} | Select-Object -ExpandProperty Version
5. while($version -ne $updatetoversion){
6. Start-Process $UpdateEXE $UpdateArguements -Wait
7. }
IAN-XEU, I ran the script several times with no issue, but today I was prompted with that box,
"There are updates available. Click OK to start upgrade."
Is there a way to bypass that? The automation breaks until someone answers YES.
Hi,
The version of Office 365 cannot be retrieved from the WMI class win32_product and it appears OfficeC2RClient.exe calls OfficeClickToRun.exe to update Office 365. If you want to update to a specified version you have to add the "updatetoversion" parameter to OfficeC2RClient. Please check to see if this works for you.
$UpdateEXE ="C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe"
$updatetoversion = "16.0.13127.21348"
$UpdateArguements = "/update user displaylevel=true updatetoversion=$updatetoversion"
$path = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
$name = "VersionToReport"
$version = Get-ItemProperty -Path $path | Select-Object -ExpandProperty $name
$ClickToRunSvc = Get-WmiObject win32_service | Where-Object { $_.name -eq 'ClickToRunSvc'}
while($version -ne $updatetoversion){
if($ClickToRunSvc.State -eq 'Stopped'){
Start-Service -Name 'ClickToRunSvc'
Start-Process $UpdateEXE $UpdateArguements -Wait
$ClickToRunSvc = Get-WmiObject win32_service | Where-Object { $_.name -eq 'ClickToRunSvc'}
}
else{
$OfficeClickToRun = Get-Process -Name OfficeClickToRun
if($OfficeClickToRun.count -eq 1){
Start-Process $UpdateEXE $UpdateArguements -Wait
}
else{
Start-Sleep -Seconds 10
}
}
$version = Get-ItemProperty -Path $path | Select-Object -ExpandProperty $name
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
So what I see from running the script, the version is what's current. Then there's the updateto.
While runs if version is less than updateto.
Then it checks the version again.
If version = previous version (which I don't see why it would), then it breaks the loop of running/checking. So that stops the PS.
If version is less than updateto, the script stops.
Why would the script run once, compare the version to the updateto, and stop on either IF? I still don't see where the Start-Process runs until the IF means version=updateto.
Why would the scriptversion ever be less than the updateto, except while the loop is running to get it there, which I think is only two runs)?
I'll test this in the morning. What I'm missing in my logic is
If the initial version is less than the uptoversion, start the exe
Then, check the version again.
If the version checked equals the previous version (which is already is in line 6)
then quit (without updating).
If the version checked is less than the updateto, quit and say no updates installed.
So I guess I'm missing where, if the script:version is less than updateto (line 14), there's no updating. Like 9 also says is the script:version -eq previous version, quit.
So where is it that says, if the script:version -ne updateto, run, then run again until it does get there? It seems that both IF's answer what happens when they don't match.
Sounds like a plan. I know it works because the Office popup tells me Updates were installed and I can verify the version of Word, Excel, etc.
But almost immediately after kicking off the PS, the DOS displays line 15 and waits for me to press a key to close it. Strange.