I have the following worklet which works fine with the exception it updates the wow64 runonce reg key install of the 64 bit runonce reg key? Anyone have any ideas how to get it to update the 64-bit key?
$ScriptBlock = {
param($tempDir = 1, $filename = 2)
$MSIPath = “$tempDir\SAPGUI_7.6_Patch3.msi”
if (-not (Test-Path -Path $MSIPath)) {
Copy-Item $filename -Destination $tempDir
}
Set-ItemProperty -Path ‘HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce’ -Name “UpdateSAPGUI” -Value “C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command ‘Start-Process -FilePath ‘msiexec.exe’ -ArgumentList (’/qn’, ‘/i’, ‘$tempDir\SAPGUI_7.6_Patch3.msi’) -Wait -Passthru’”
}
$args=@("$env:windir\Temp", $filename)
$returnCode = & “$env:SystemRoot\system32\WindowsPowerShell\v1.0\powershell.exe” -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -NonInteractive -Command $scriptblock -args $args
exit $returnCode