I need to run a script as a user to remove the new windows 10 “let’s finish setting up your device” after the 2004 update that only offer a “remind me in 3 days” button.
This is my script but when I run it form simplehelp toolbox it is running as Local System and the change are done to HKEY_USERS\S-1-5-18 instead of the current user.
Any tips to run this from the toolbox as the local user ?
set __COMPAT_LAYER=RunAsInvoker
REGEDIT.EXE /S c:\temp\engagementfix.reg
REGEDIT.EXE /S c:\temp\suggestedcontent.reg
content of the reg files :
suggestedcontent.reg
Windows Registry Editor Version 5.0
Then you can use that $currentUsername to search through the profilelist key of registry
#Look in the ProfileList registry to find the corresponding SID
$profileListPath = “Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList”
$profiles = Get-ChildItem -Path $profileListPath
foreach ($profile in $profiles) {
$profileImagePath = (Get-ItemProperty -Path “registry::$profile”).ProfileImagePath
if ($profileImagePath -like “*$currentUsername”) {
# Extract the SID from the ProfileList registry key name
$userSID = $profile.Name.Split('')[-1]
then you can create a runonce key for the current user to run a .bat file to “merge a .reg file” when they log back on next…
#Construct the RunOnce key path for the user’s registry hive
$runOnceKeyPath = “Registry::HKEY_USERS$userSID\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce”
#Define the command you want to run as a RunOnce entry
$commandToRun = “C:\Location of file\Name of file.bat”
#Add the command to the RunOnce key of the user’s registry hive
New-Item -Path $runOnceKeyPath -Force
New-ItemProperty -Path $runOnceKeyPath -Name “TempRunOnceName” -PropertyType String -Value $commandToRun
Write-Host “RunOnce entry added for user SID: $userSID”
break
}
}
If that makes sense?
I got this working in another system we use to deploy scripts and etc… when script is running as “System” I am converting to SimpleHelp to test it there as well…
Specifying the user you want to run it has is a little more difficult, but if its just the current logged in user, that’s easy. Select currently logged in user from the drop down in the configuration of your toolbox.