shiv Posted February 12, 2014 Share Posted February 12, 2014 I am using the below mentioned function to delete the registry key. However it is working fine almost all of the scripts. But i have encountered a new issue with this function In the Below mentioned function Func _DeleteRegistry($sKeyname, $sValuename) Local $iOutput Local $sRemark If $sValuename == "" Then $iOutput = RegDelete($sKeyname) Else $iOutput = RegDelete($sKeyname, $sValuename) EndIf If $iOutput == 1 Then ConsoleWrite("Registry"&" "&$sValuename&" " &"has been deleted successfully." & @CRLF) Else ConsoleWrite("Registry"&" "&$sValuename&" " &"has not deleted " & @CRLF) EndIf Return $sRemark EndFunc In the above mentioned function $sKeyname is : HKEY_CURRENT_USERSOFTWAREpostserverservername here "servername" is the subkey of server and $sValuename in the function is "p" which is of type "binary" I just want to delete this "p" registry but when i running the below mentione program it is deleting the whole subkey "$sKeyname" Please suggest what to do Link to comment Share on other sites More sharing options...
shiv Posted February 12, 2014 Author Share Posted February 12, 2014 ?? Link to comment Share on other sites More sharing options...
ripdad Posted February 12, 2014 Share Posted February 12, 2014 _DeleteRegistry("HKEY_CURRENT_USER\SOFTWARE\post\server\servername", "p") "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
shiv Posted February 14, 2014 Author Share Posted February 14, 2014 Thanks, But as i told you it is deleting the key "servername" Actually key servername is not the default key it is made during running the application with value "p" of binary type servername is the subkey created under server Even RegRead is also not able to read the "P" However it is deleting the the whole key "Servername" please....... provide some way to do this Link to comment Share on other sites More sharing options...
Country73 Posted February 14, 2014 Share Posted February 14, 2014 May need to check the values that are being sent to the function. Notice first entry in the Function to display what is being passed. Just duplicated your post, creating a bogus entry, and was able to delete the "p" while keeping the "servername" key. $myValue = _DeleteRegistry($sKeyname,$sValuename) ConsoleWrite($myValue & @CRLF) Func _DeleteRegistry($sKeyname, $sValuename) ConsoleWrite('RegDelete("' & $sKeyname & '","' & $sValuename & '")' & @CRLF) Local $iOutput Local $sRemark If $sValuename == "" Then $iOutput = RegDelete($sKeyname) Else $iOutput = RegDelete($sKeyname, $sValuename) EndIf If $iOutput == 1 Then ConsoleWrite("Registry"&" "&$sValuename&" " &"has been deleted successfully." & @CRLF) Else ConsoleWrite("Registry"&" "&$sValuename&" " &"has not deleted " & @CRLF) EndIf Return $sRemark EndFunc If you try to fail and succeed which have you done?AutoIt Forum Search Link to comment Share on other sites More sharing options...
shiv Posted March 7, 2014 Author Share Posted March 7, 2014 I am sorry could not update you because of some strange reason But Still not able to delete the registry . I think we can not delete the registry key under subkey of subkey of any registry. I try to explain it with more information My Registry path is: HKEY_CURRENT_USERSoftwareOrgClientthis.id.com Here this.id.com <subkey of>Client <subkey of> Org [Hope here you understood the hierarchy] Now ..."this.id.com" has the two registry keys "p" and "q" of type binary with some random value. i just want to delete this "p". I have tried the above mentioned function but it is unable to find "p" and therefor it deletes the complete "this.id.com" which as a result delete the "p" and "u" both. which fails my script Please help is there is some other way to do it . Link to comment Share on other sites More sharing options...
ripdad Posted March 7, 2014 Share Posted March 7, 2014 Please show the code that you use to write the registry entries. A reproducer snippet of code, would be most helpful. "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
shiv Posted March 11, 2014 Author Share Posted March 11, 2014 Hi you can understand from the fn below and both are not working. i am afraid that may be a bug. Func _IsRegistryPresent($sRegPath, $sKeyname) Local $ReadRegistry = RegRead($sRegPath,$sKeyname) if @error Then ConsoleWrite("Registry with value" &$sKeyname& "is not found " & @CRLF) Else ConsoleWrite("Registry"&" "&$sKeyname&" "&"has been found" & @CRLF) EndIf Return $sRemark EndFunc Func _DeleteRegistry($sKeyname, $sValuename) Local $iOutput = RegDelete($sKeyname, $sValuename) If $iOutput == 1 Then ConsoleWrite("Registry"&" "&$sValuename&" " &"has been deleted successfully." & @CRLF) Else ConsoleWrite("Registry"&" "&$sValuename&" " &"has not deleted." & @CRLF) EndIf Return $sRemark EndFunc Link to comment Share on other sites More sharing options...
ripdad Posted March 11, 2014 Share Posted March 11, 2014 Using your longhand scripting, try this and let me know if you have any errors. expandcollapse popupLocal $sKey = 'HKEY_CURRENT_USER\Software\_TEST_2014' Local $sVal = 'p' ; 1 = Success ; 0 = Failed ; Run Test ;=============================================================== Local $rtn = _RegWriteValue($sKey, $sVal, 'REG_SZ', '12345') MsgBox(0, '_RegWriteValue', $rtn) $rtn = _IsValuePresent($sKey, $sVal) MsgBox(0, '_IsValuePresent', $rtn) If $rtn Then $rtn = _DeleteValueName($sKey, $sVal) MsgBox(0, '_DeleteValueName', $rtn) EndIf If $rtn Then $rtn = _DeleteKeyName($sKey) MsgBox(0, '_DeleteKeyName', $rtn) EndIf ;=============================================================== ; End Test Func _IsValuePresent($sKeyname, $sValuename) RegRead($sKeyname, $sValuename) If Not @error Then ConsoleWrite('Value Exist: ' & $sKeyname & ':' & $sValuename & @CRLF) Return SetError(0, 0, 1) Else ConsoleWrite('Value Not Found: ' & $sKeyname & ':' & $sValuename & @CRLF) Return SetError(1, 0, 0) EndIf EndFunc Func _DeleteValueName($sKeyname, $sValuename) If RegDelete($sKeyname, $sValuename) Then ConsoleWrite('Success - Delete ValueName: ' & $sKeyname & ':' & $sValuename & @CRLF) Return SetError(0, 0, 1) Else ConsoleWrite('Error - Delete ValueName: ' & $sKeyname & ':' & $sValuename & @CRLF) Return SetError(1, 0, 0) EndIf EndFunc Func _DeleteKeyName($sKeyname) If RegDelete($sKeyname) Then ConsoleWrite('Success - Delete KeyName: ' & $sKeyname & @CRLF) Return SetError(0, 0, 1) Else ConsoleWrite('Error - Delete KeyName: ' & $sKeyname & @CRLF) Return SetError(1, 0, 0) EndIf EndFunc Func _RegWriteValue($sKeyname, $sValuename, $sType, $sValue) If RegWrite($sKeyname, $sValuename, $sType, $sValue) Then ConsoleWrite('Success - Write Value: ' & $sKeyname & ':' & $sValuename & @CRLF) Return SetError(0, 0, 1) Else ConsoleWrite('Error - Write Value: ' & $sKeyname & ':' & $sValuename & @CRLF) Return SetError(1, 0, 0) EndIf EndFunc "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
shiv Posted March 11, 2014 Author Share Posted March 11, 2014 Thanks for reply The functions which i mentioned above are working fine now.however i did not made any change in them I do not know why the same functions were failing before. Link to comment Share on other sites More sharing options...
ripdad Posted March 13, 2014 Share Posted March 13, 2014 Well, in any case -- I'm glad you got it working. "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward 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