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,
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"
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.
- Apr 26, 2021Hi
Yes it's a little bit complicated... I just used this script which I had to control the oobe settings before the user logged on. Maybe it could be a little bit stripped down but it does the job 🙂 . The schedule part was meant for scheduling 🙂- Ondrej_SKApr 26, 2021Copper ContributorIf the schedule part is only for scheduling, i do not understand how can i use it without it, to go around the problem of starting powershell in 64 bit mode to access the registry. Could you please explain?
- Apr 26, 2021Hi,
I guess my reply is/was missing the last part.
The schedule part was meant for scheduling :). But you don't need to schedule it to run at each user login, just let it run once and delete it after the task was run.
Unregister-ScheduledTask -TaskName testreg -Confirm:$false