JakeHelpdesk Posted September 24, 2014 Posted September 24, 2014 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?
JohnOne Posted September 24, 2014 Posted September 24, 2014 return values? @error? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JakeHelpdesk Posted September 24, 2014 Author Posted September 24, 2014 For the Local Machine it's returning 1 (unable to open requested key) For the Current User it's returning 0 (success) I don't understand why it's unable to open requested key. I am able to do it manually, I am a local administrator on the PC.
Gianni Posted September 24, 2014 Posted September 24, 2014 .....I have also tried editing the registry with a batch file (That Works) ..... could you post the batch file? Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
JakeHelpdesk Posted September 24, 2014 Author Posted September 24, 2014 (edited) 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 September 24, 2014 by JakeHelpdesk
Solution jguinch Posted September 24, 2014 Solution Posted September 24, 2014 (edited) 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 September 24, 2014 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Moderators JLogan3o13 Posted September 24, 2014 Moderators Posted September 24, 2014 (edited) @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 September 24, 2014 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!
JakeHelpdesk Posted September 24, 2014 Author Posted September 24, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now