Issue with worklet updating registry.

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

I believe that this bit here needs to go to /sysnative/ instead of/system32/


But I’m on mobile so I can’t check it.

1 Like


There is no /sysnative/ directory on any of these Windows 10 workstations?

Right, it doesn’t actually exist. It’s a virtual path used when you’re running a 32bit shell. It prevents the shell from redirecting to SysWow64 instead of going to the native System32 directory.