Jump to content

RegDelete


Recommended Posts

I’m fairly new to AutoIT, and I’m having difficulty fully understanding some of the registry functions.

RegDelete will delete a key or value. It seems to be the case that a subkey cannot be deleted on its own. I need confirmation of my understanding of how the following RegDelete would be executed:

RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\uvnc_service")

I would like to delete ONLY the subkey – “uvnc_service”, but the way I read AutoIT’s help file on RegDelete, every entry below the subtree – “HKEY_LOCAL_MACHINE\SYSTEM” would be deleted.

I need confirmation that my understanding is correct, or if not, an explanation of just what would be deleted. Any help would be greatly appreciated.

BillH

Link to comment
Share on other sites

It should only delete the last segment or, if specified, the value. Anything else will be a bug :idea:

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

It should only delete the last segment or, if specified, the value. Anything else will be a bug :idea:

Thank you for the explanation. I now know RegDelete works as I need it to. I appreciate the prompt response.

BillH

Link to comment
Share on other sites

I have another question with regard to RegRead. I would like to use the following RegRead to determine if the last segment “uvnc_service” exists:

"If RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\uvnc_service") = "" Then"

I know that the null will be returned if I query a value that doesn’t exist, but is the same true if I query a non existant last segment in the same way?

Thank you,

BillH

Link to comment
Share on other sites

Check the @Error return code to see what problems there are. For just testing with RegRead() I would test for the default value.

The error codes are given in the help file under RegRead()

RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\uvnc_service")
MsgBox(0, "Error result", @Error)

EDIT: I guess I should have mentioned that you can use RegEnumKey() to determine if a key is valid or Not. In your case you would enumerate

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\

looking for uvnc_service

$i = 1
While 1
   $hEnum = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network", $i)
   If @Error Then ExitLoop
   If $hEnum = "uvnc_service" Then
      MsgBox(0, "Result", "Key Found")
      ExitLoop
   EndIf
   $i += 1
Wend
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thank you both for the assistance.

I was looking for a way to determine if the subkey uvnc_service is valid or not. RegEnumKey() meets that need nicely.

Once the subkey uvnc_service is determined to be valid I need to delete that subkey, and that subkey alone. I was unsure of just how RegDelete functioned. I now know that in the scenario I described it will only delete the last segment or, if specified, the value. I didn’t want to risk deleting more of that key than I cared to.

There’s a bit of a learning curve here, and I very much appreciate your responses.

BillH

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...