Jump to content

RegWrite RequireAdmin Still no Luck for HKLM


Go to solution Solved by jguinch,

Recommended Posts

I have the following code as an example of my problem.

#RequireAdmin
RegWrite("HKEY_LOCAL_MACHINE\Test", "Test", "REG_SZ", "TestValue")
RegWrite("HKEY_CURRENT_USER\Test", "Test", "REG_SZ", "TestValue")

I can execute this and the "HKEY_CURRENT_USERTest" will be created, but the "HKEY_LOCAL_MACHINETest" will not.

I have also tried editing the registry with a batch file (That Works)

But If I call the batch file from within AutoIt, via Run() or RunWait() it doesn't work.

Any Ideas as to why I would be prevented from writing to the HKEY_LOCAL_MACHINE?

Link to comment
Share on other sites

I was trying to do this as a test, but here is what I'm actually working on.

This is the Batch File I'm trying to convert to an AutoIt Script.

REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "LegalNoticeCaption" /t REG_SZ /d "Legal Notice" /f

REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "LegalNoticeText" /t REG_SZ /d "This system is restricted to authorized users for legitimate business purposes and is subject to audit.  The actual or attempted unauthorized access, use, modification or copying of computer systems is a violation of Local laws." /f

REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "PasswordExpiryWarning" /t REG_DWORD /d 00000000 /f

exit

This is the AutoIt Code I have put together

#RequireAdmin
RegWrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "REG_SZ", "Legal Notice")
MsgBox(0, "Error", @error)
RegWrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeText", "REG_SZ", "This system is restricted to authorized users for legitimate business purposes and is subject to audit.  The actual or attempted unauthorized access, use, modification or copying of computer systems is a violation of Local laws.")
MsgBox(0, "Error", @error)
RegWrite("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "PasswordExpiryWarning", "REG_DWORD", 0)
MsgBox(0, "Error", @error)

The 3 MsgBoxes are throwing zeros meaning it works, but when I open regedit they aren't there.

Also, if I call the Batch File

Run('C:\Scripting\Temp\LegalNotice.bat')

That doesn't work either.

However if I just run the batch file from windows, it creates the keys fine.

Edited by JakeHelpdesk
Link to comment
Share on other sites

  • Solution

Be careful : if you are using a x64 operating system, maybe you have to use HKLM64 to write these values in the good key :

#RequireAdmin
RegWrite("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "REG_SZ", "Legal Notice")
Edited by jguinch
Link to comment
Share on other sites

  • Moderators

@OP - I realize you're trying to create in the Winlogon key, but please see below for why your original test (HKLMTest) was failing:

from the help file (which took it from MSDN):

An application cannot create a key that is a direct child of HKEY_USERS or HKEY_LOCAL_MACHINE. An application can create subkeys in lower levels of the HKEY_USERS or HKEY_LOCAL_MACHINE trees.



As has been pointed out, it is probably creating, but going into your Wow6432Node

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

 

Be careful : if you are using a x64 operating system, maybe you have to use HKLM64 to write these values in the good key :

#RequireAdmin
RegWrite("HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "LegalNoticeCaption", "REG_SZ", "Legal Notice")

I could have sworn I tried that already..... but I just did what you said again, and it's working.

Thank you so much for your help

Sincerely,

Jake

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...