Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

NEW Reg Query fails as admin

  • Thread starter Thread starter pcb
  • Start date Start date
  • Replies Replies 1
  • Views Views 1K

pcb

Well-Known Member
Messages
45
Solutions
2
Reaction score
0
Points
6
The following command is successful when logged in locally and run as admin at the desktop - it is also successful when running as NT Authority\System via psexec -i -s cmd.exe - the registry key is found and the variables get set correctly

For /F "Tokens=3 delims= " %%i IN ('REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\LCC\DEVICE ^| findstr "Behavior"') Do (
Set "SearchFile=%~dp0cleanupSearch.%%i.txt"
set "excludeFile=%~dp0cleanupExclusion.%%i.txt"
)
When I put it in a package and set it to run whether or not someone is logged in and check "allow users to interact", I see that the registry key is not found.
Unchecking the box "allow users to interact" also results in failure... -- I added a whoami command to the script and confirmed that in this condition it runs as nt authority\system!

Running as the logged in user via sccm also fails to find the registry key... but running the command manually at the desktop as the logged in user is successful.

Is sccm somehow blocked from reading HKLM???? I am seriously confused. Anyone know what I'm doing wrong?
 
Ok so I figured it out. MECM runs packages as 32 bit which prevents access to the 64bit registry. I need the script to run on logon of each user and really don't want to put this in task scheduler... Anyone know how?
 

Forum statistics

Threads
7,135
Messages
27,868
Members
18,159
Latest member
jordysmits
Back
Top