wurmz Posted December 28, 2012 Share Posted December 28, 2012 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 More sharing options...
Developers Jos Posted December 28, 2012 Developers Share Posted December 28, 2012 Do you have a x64 OS and running this script with the x86 version of AutoIT3.exe? 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 More sharing options...
wurmz Posted December 28, 2012 Author Share Posted December 28, 2012 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 28, 2012 Developers Share Posted December 28, 2012 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 More sharing options...
wurmz Posted December 28, 2012 Author Share Posted December 28, 2012 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. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 28, 2012 Developers Share Posted December 28, 2012 (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 December 28, 2012 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 More sharing options...
wurmz Posted December 28, 2012 Author Share Posted December 28, 2012 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 More sharing options...
Developers Jos Posted December 28, 2012 Developers Share Posted December 28, 2012 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.expandcollapse popup; *** 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 More sharing options...
iamtheky Posted December 28, 2012 Share Posted December 28, 2012 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 More sharing options...
wurmz Posted December 28, 2012 Author Share Posted December 28, 2012 @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 More sharing options...
Developers Jos Posted December 28, 2012 Developers Share Posted December 28, 2012 ...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 More sharing options...
wurmz Posted December 29, 2012 Author Share Posted December 29, 2012 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. Link to comment Share on other sites More sharing options...
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