RegSetValue

Started by jack, June 21, 2023, 09:18:13 PM

Previous topic - Next topic

jack

It has been years since I scripted in Winbatch.

I think in 2008 I wrote a When batch script That I also compiled. It made some minor edits to the registry.
It sets some registry so that. The user would not have to log in.

Worked perfectly well in Windows 7 When I first wrote it. Still works well in Windows 10. However, It seems to have stopped working in Windows 7.

I can. With the value exists And I could Read the value into my script. However, When I try to set the value, I get the error
"

"1452: REG Functions: Unable to open (or create) specified subkey"

My CODE********************************This works
reg = RegExistValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion[RegisteredOwner]")
if reg <> 0
   RegOwner=RegQueryValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion[RegisteredOwner]")
endif

reg = RegExistValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion[RegisteredOrganization]")
if reg <> 0
   RegOrg=RegQueryValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion[RegisteredOrganization]")
endif

reg = RegExistValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[DefaultUserName]")
if reg <> 0
   UserName=RegQueryValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[DefaultUserName]")
   LogonName = @True
endif

reg = RegExistValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[DefaultPassword]")
if reg <> 0
   Password=RegQueryValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[DefaultPassword]")
   LogonPass = @True
endif

reg = RegExistValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[AutoAdminLogon]")
if reg <> 0
   Enabled=RegQueryValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[AutoAdminLogon]")
   LogonEnabled = @True
endif

My CODE******************************** That fails
RegSetValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion[RegisteredOwner]", RegOwner, 0)
RegSetValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion[RegisteredOrganization]", RegOrg, 0)

RegSetValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[DefaultUserName]",UserName, 0)
RegSetValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[DefaultPassword]",Password, 0)
RegSetValue(@REGMACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon[AutoAdminLogon]",Enabled, 0)








td

Keys and values under HKEY_LOCAL_MACHINE require elevated administrator privileges to modify but only regular user privileges to read. This means that your problem is likely the result of executing your failing script with insufficient privileges.

The function documentation can be found here:
https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/WILLZ_R__008.htm

Note the sentence immediately preceding the function example.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade