Sign in to follow this  
Followers 0
wurmz

RegDelete Problem

12 posts in this topic

When I try to use this, I just get an error -2 or 0. I haven't gotten it to run successfully yet. The logic seems correct and the MsgBox I coded in to test the output is correct..... I'm stumped.

#include

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate("Reg Key Delete", 250, 100)
$input1 = GUICtrlCreateInput("", 40, 20, 170)
$button1 = GUICtrlCreateButton("Delete Reg Keys", 40, 50, 170)
GUICtrlSetOnEvent($button1, "DelButton")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState(@SW_SHOW)

While 1
Sleep(1000) ; Idle around
WEnd

Func DelButton()
$data = GUICtrlRead($input1)
; just a test ; MsgBox( 0, "test", "\\" & $data & "\HKLM\Software\Microsoft\MSLicensing\Store", 0)
RegDelete("\\" & $data & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\HardwareID")
$regdelstore = RegDelete("\\" & $data & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\HardwareID")
If $regdelstore = 1 Then
MsgBox(0, @ScriptName, "Key deleted succefully.")
ElseIf $regdelstore = 0 Then
MsgBox(0, @ScriptName, "Key does not exist or " & $data & " was not found.")
ElseIf $regdelstore = 2 Then
MsgBox(0, @ScriptName, @error & ": Error deleting key.")
Else
MsgBox(0, @ScriptName, "Script just tried to delete the ""Store"" reg key, but we don't know what happend")
EndIf
EndFunc

Func CLOSEClicked()
Exit
EndFunc

Share this post


Link to post
Share on other sites



Actually yes, but I have tried a combination of compiling it in x86 and x64 and I ran it from an XP machine using the x86 version. Still fails.

Share this post


Link to post
Share on other sites

Reason for asking was that you else need to check the wow3264node hive.

So you are trying to do a delete of the registry key on a remote computer... are you sure you have enough rights to do this when the script is shelled?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

100% sure I have the rights.

All machines I would ever delete on would be 32bit, so I wouldn't need to worry about 64bit entries.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

any reason you are running the command 2 times?

RegDelete("" & $data & "HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSLicensingHardwareID")

$regdelstore = RegDelete("" & $data & "HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSLicensingHardwareID")

The second one should always fail in this way.

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

New code, still fails:

#include 

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate("Reg Key Delete", 250, 100)
$input1 = GUICtrlCreateInput("", 40, 20, 170)
$button1 = GUICtrlCreateButton("Delete Reg Keys", 40, 50, 170)
GUICtrlSetOnEvent($button1, "DelButton")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState(@SW_SHOW)

While 1
Sleep(1000) ; Idle around
WEnd

Func DelButton()
$data = GUICtrlRead($input1)
; just a test ; MsgBox( 0, "test", "\\" & $data & "\HKLM\Software\Microsoft\MSLicensing\Store", 0)
$regdelstore = RegDelete("\\" & $data & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\HardwareID")
If $regdelstore = 1 Then
MsgBox(0, @ScriptName, "Key deleted succefully.")
ElseIf $regdelstore = 0 Then
MsgBox(0, @ScriptName, "Key does not exist or " & $data & " was not found.")
ElseIf $regdelstore = 2 Then
MsgBox(0, @ScriptName, @error & ": Error deleting key.")
Else
MsgBox(0, @ScriptName, "Script just tried to delete the ""Store"" reg key, but we don't know what happend")
EndIf
EndFunc

Func CLOSEClicked()
Exit
EndFunc

Share this post


Link to post
Share on other sites

Code looks good. Are you still getting an @error=-2 when running this for a remote WinXP?

I have tested on my Win7 X64 machine running the code from SciTE with RUn, but SciTE is running as Administrator at the time I pressed F5.

Code worked fine and deleted the Key.

; *** Start added by AutoIt3Wrapper ***
#include  <GUIConstantsEx.au3>
; *** End added by AutoIt3Wrapper ***
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
$mainwindow = GUICreate("Reg Key Delete", 250, 100)
$input1 = GUICtrlCreateInput(@ComputerName, 40, 20, 170)
$button1 = GUICtrlCreateButton("Delete Reg Keys", 40, 50, 170)
GUICtrlSetOnEvent($button1, "DelButton")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState(@SW_SHOW)

While 1
Sleep(1000) ; Idle around
WEnd

Func DelButton()
$data = GUICtrlRead($input1)
; just a test ; MsgBox( 0, "test", "\\" & $data & "\HKLM\Software\Microsoft\MSLicensing\Store", 0)
$regdelstore = RegDelete("\\" & $data & "\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\HardwareID")
If $regdelstore = 1 Then
MsgBox(0, @ScriptName, "Key deleted succefully.")
ElseIf $regdelstore = 0 Then
MsgBox(0, @ScriptName, "Key does not exist or " & $data & " was not found.")
ElseIf $regdelstore = 2 Then
MsgBox(0, @ScriptName, @error & ": Error deleting key.")
Else
MsgBox(0, @ScriptName, "Script just tried to delete the ""Store"" reg key, but we don't know what happend")
EndIf
EndFunc ;==>DelButton

Func CLOSEClicked()
Exit
EndFunc ;==>CLOSEClicked

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

can you write something there locally, and then delete what you wrote?

If so can you then do the same thing to a remote system?

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\HardwareID" , "test" , "REG_SZ" , "testkey")
$read = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\HardwareID" , "test")
msgbox (0, '' , $read)

$regdelstore = RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSLicensing\HardwareID" , "test")
If $regdelstore = 1 Then
MsgBox(0, @ScriptName, "Key deleted succefully.")
ElseIf $regdelstore = 0 Then
MsgBox(0, @ScriptName, "Key does not exist or was not found.")
ElseIf $regdelstore = 2 Then
MsgBox(0, @ScriptName, @error & ": Error deleting key.")
Else
MsgBox(0, @ScriptName, "Script just tried to delete the ""Store"" reg key, but we don't know what happend")
EndIf

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

@Jos - Yes, I still get a -2 error.

@boththose - I haven't tried using the write command yet, but I have tried hardcoding in the computer name instead of using the $data variable and it fails that way as well.

Well, I'm going to toy with this again next week, but this is my last post allowed for the day, so thanks for the help, I will update this when I get more time to play with the script.

Share this post


Link to post
Share on other sites

Thanks for that Jos, I will come back to this script next week, for now I started a new project that I've created a new thread for.

Share this post


Link to post
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
Sign in to follow this  
Followers 0