I am using MS Server 2012 R2 64bit with Active Directory installed. I want to execute a few batch scripts when the user logs into a computer. These scripts use the "reg add/query" commands to check if a registry key exists and if it doesn't it will create it and set a value to the new key. The problem I'm having is that it seems that every time the scripts run when a user executes, the scripts attempt to execute the reg add/query commands and it gets an "access denied" message. Here is a sample of my batch script:
reg query HKCU\Software\myownkey >null 2>&1
if %ERRORLEVEL%% NEQ 0 (
echo myownkey doesn't exist. Must create it.
reg add HKCU\Software /v myownkey /t REG_DWORD /f /d 1 >null 2>&1
)
PAUSE
When the user logs into the machine, the script is executed and then it pauses so I can see if the script executed properly or not. All I see is that it prints "Access Denied" every time it attempts to query/add the registry.
Any one knows how to solve this problem? Am I better off using powershell scripts instead and won't run into this problem?
Thank you in advanced!