AutomoxAutomox

Issue with worklet updating registry.

jim.collier
January 28, 2020 at 1:14 pm UTC

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

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (3)

Rich-AutomoxJanuary 28, 2020
#1

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

$env:SystemRoot\system32\WindowsPowerShell\v1.0\powershell.exe

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

jim.collierJanuary 28, 2020
#2

Hi,

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

Rich-AutomoxJanuary 28, 2020
#3

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.