Jump to content

RegDelete Problem


wurmz
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Developers

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?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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

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

Link to comment
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.

Link to comment
Share on other sites

  • Developers

...but this is my last post allowed for the day,

That should be fixed now and should be able to post.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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