Forum Discussion
Win32 App Powershell 64bit registry access issue
- Apr 26, 2021
Hi,
Please take a look at
Sysnative | Intune | 64 VS 32 Bits | Registry Keys (call4cloud.nl)What happens when you run a script with setting this option to yes instead of no
Hi,
Please take a look at
Sysnative | Intune | 64 VS 32 Bits | Registry Keys (call4cloud.nl)
What happens when you run a script with setting this option to yes instead of no
- Ondrej_SKApr 27, 2021Copper Contributor
Rudy_Ooms_MVP So once Rudy pointed out that the sysnative is only accessible from 32bit consoles, i have tested and voila, the script is working like a charm! I have used a separate one line script to start the install script:
Start-Process -FilePath "$ENV:WINDIR\SysNative\WindowsPowershell\v1.0\PowerShell.exe" -ArgumentList "-File `"$($PSScriptRoot)\registry.ps1`" " -Wait -NoNewWindow
Happy ending of a thread 😄
- BoxApr 15, 2023Copper ContributorYou can directly use this in Intune command line to launch powershell as x64:
%windir%\SysNative\WindowsPowershell\v1.0\PowerShell.exe -NoProfile -ExecutionPolicy ByPass -File .\MyScript.ps1
- Apr 26, 2021Hi
I have got one idea, after my lunch i will test it out and let you know- MohasineNov 13, 2024Copper Contributor
Did we find any solution to the above problem?
I am using CMD file to call my Powershell Script and inspite of writing REG value to Software its writing it to Syswow64.
- Ondrej_SKApr 26, 2021Copper Contributor
Hi, thank you for the links, however i have read those articles already.
And as i wrote, SysNative directory is not present Windows 10 anymore.
I cannot use a Powershell script as it is not bringing any files for installation an cannot be published for the user to install.
However i have tested the script to be run in 64 bit host and it correctly created the key and value.
I cannot use the script as a dependency for a win32 app however.
- Apr 26, 2021
Hi,
You could create something like this and convert it (with the msi) to a intunewin file
Just like i I did with a win32 app to disable the oobe stage (for when you don't use autopilot)
:
https://call4cloud.nl/2020/10/the-curious-cage-of-hiding-the-oobe-stage/
I uploaded the app just a few seconds ago,first I need to spin up a clean windows 10 test vm. I will let you know the outcome. UPDATE 14:05: The registry keys were succefully created. Of course, I skipped the msi part but I this something you could use?
-----
$content = @'
$flexreg = (Get-ItemProperty "HKLM:\Software\FLEXlm License Manager").SW_D_LICENSE_FILE
#Start-Process -Wait -NoNewWindow "msiexec" -ArgumentList "/i","$pwd\DraftSight.msi","/qb","LICENSETYPE=3"
if (!$flexreg) {
New-Item -Path "HKLM:\Software" -Name "FLEXlm License Manager" -Force
New-ItemProperty "HKLM:\Software\FLEXlm License Manager" -Name "SW_D_LICENSE_FILE" -Value 'portnr@servername' -PropertyType STRING -Force
} elseif ($flexreg -like '*portnr@servername*') {
Exit
} else {
New-ItemProperty "HKLM:\Software\FLEXlm License Manager" -Name "SW_D_LICENSE_FILE" -Value $flexreg';portnr@servername' -PropertyType STRING -Force
}
'@
Out-File -FilePath $(Join-Path $env:ProgramData CustomScripts\testreg.ps1) -Encoding unicode -Force -InputObject $content -Confirm:$false
# register script as scheduled task
$Time = New-ScheduledTaskTrigger -AtLogOn
$User = "SYSTEM"
$Action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ex bypass -file `"C:\ProgramData\CustomScripts\testreg.ps1`" -Verb RunAs"
Register-ScheduledTask -TaskName "testreg" -Trigger $Time -User $User -Action $Action -Force
Start-ScheduledTask -TaskName "testreg"- Ondrej_SKApr 26, 2021Copper ContributorWoah. So you pack the script to a file, register a Scheduled task and execute it so that a new instance is executed in 64 bit. Is task scheduler using %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe due to system default?
This is quite a stretch to get it working. Registering a scheduled task for each powershell installation that needs to work with registry and cleanup the scheduled task (with detection script for example)
Don't take me wrong you seem to have a workaround, but its quite complicated.
But you gave me an idea. i have to test to call %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe from a batch file with start command.