pascal Posted October 8, 2009 Posted October 8, 2009 Hello everybody, I'm desperate, I'm trying to do my first AutoIt script to uninstall Symantec products from my consumer's computer stations. I take sample from this forum, that seems nice and easy. Well go on. But I've ever got compilation errors, I don't understand where is the mistake. Aut2exe only returns compilation error code 65535, nice the size of a short integer, but this doesn't help me. Could you please help me ? Func RegUninstallStringFind($szFind) Local $index, $subkey, $sRet, $sBuff Local Const $HKLM_UNINSTALL = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $sRet = "" $index = 1 While 1 $subkey = RegEnumKey($HKLM_UNINSTALL, $index) If @error Then ExitLoop $sBuff = RegRead($HKLM_UNINSTALL & "\" & $subkey, "DisplayName") If StringInStr($sBuff, $szFind) Then $sRet = RegRead($HKLM_UNINSTALL & "\" & $subkey, "UninstallString") ExitLoop EndIf $index = $index + 1 WEnd Return $sRet EndFunc ;==>RegUninstallStringFind $a = "" ; change the search string accordingly $a = RegUninstallStringFind("Symantec AntiVirus") If $a <> "" Then Local $cmd $cmd = StringReplace( $a, "/I", "/norestart /qn /x" ) $cmd &= " REMOVE=ALL" ; this is just a test line to make sure it works MsgBox(0, "", "This is your uninstall command:" & $a) EndIf Is there a way to get more informations about compilation mistake ?
ctyankeeinok Posted October 8, 2009 Posted October 8, 2009 Two problems: 1. I think you are missing an EndIF on the If @error line. 2. @error is not a boolean.
ctyankeeinok Posted October 8, 2009 Posted October 8, 2009 and another... StringInStr returns a position (integer), not a boolean
wolf9228 Posted October 8, 2009 Posted October 8, 2009 No errors in the Compiling Try Compiling From SciTE Script Editor Tools ===> Build Will come later صرح السماء كان هنا
PsaltyDS Posted October 8, 2009 Posted October 8, 2009 On 10/8/2009 at 2:25 PM, 'ctyankeeinok said: and another... StringInStr returns a position (integer), not a boolean That's not a syntax error in AutoIt: If StringInStr($sBuff, $szFind) Then AutoIt does not use strong typing of variables. It will make some attempt to convert types. If the test string is not present StringInStr() returns 0, else it returns an integer position. Since on Boolean compare 0=False and all other numbers=True, this is a valid test if string $szFind is present in $sBuff. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
pascal Posted October 8, 2009 Author Posted October 8, 2009 Many thanks ctyankeeinok, it seems to work fine wolf9228, I'm using ScieTE Script Editor but it doesn't return any usefull informations. I'm used to work with many programming languages and this is the first I see a so silent compiler
PsaltyDS Posted October 8, 2009 Posted October 8, 2009 On 10/8/2009 at 3:37 PM, 'pascal said: Many thanks ctyankeeinok, it seems to work fine wolf9228, I'm using ScieTE Script Editor but it doesn't return any usefull informations. I'm used to work with many programming languages and this is the first I see a so silent compiler The code in the OP compiles and runs correctly for me on both the current production and beta versions. What are you running it on, and with what version of AutoIt? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
wolf9228 Posted October 8, 2009 Posted October 8, 2009 On 10/8/2009 at 2:25 PM, 'ctyankeeinok said: and another... StringInStr returns a position (integer), not a booleanYes, correct informationBut the logic operation is also correctFailure: Returns 0 / FalseSuccess: Returns the position of the substring position Starts from one to infinity / True صرح السماء كان هنا
pascal Posted October 8, 2009 Author Posted October 8, 2009 On 10/8/2009 at 3:44 PM, 'PsaltyDS said: The code in the OP compiles and runs correctly for me on both the current production and beta versions. What are you running it on, and with what version of AutoIt? Compiler doesn't return version in the about, but I've download it 3 days ago, so this is the last stable version 3, and it's running on Vista. But don't mind, it works well, I understand troubles, I've got this last days.
ctyankeeinok Posted October 8, 2009 Posted October 8, 2009 PSaltyDS - Thanks for the correction/clarification on the boolean - I learned a new thing. I still don't see how it would work properly with the missing EndIf.
PsaltyDS Posted October 8, 2009 Posted October 8, 2009 On 10/8/2009 at 4:01 PM, 'ctyankeeinok said: I still don't see how it would work properly with the missing EndIf. The EndIf is not missing in the actual code. I only quoted the line with the Boolean compare in it. It can also be correct to have If without EndIf, but only if it's a complete one-line statement with the conditional action on the same line. For example: If $n = 1 Then $s = "One" EndIf ; Can be replaced with: If $n = 1 Then $s = "One" Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Vakari Posted October 8, 2009 Posted October 8, 2009 (edited) Edit: Looks like PsaltyDS beat me to it On 10/8/2009 at 4:01 PM, 'ctyankeeinok said: PSaltyDS - Thanks for the correction/clarification on the boolean - I learned a new thing. I still don't see how it would work properly with the missing EndIf. If your statement moves on to only a single line of code, you can place "Then ..." all on the same line and exclude the EndIf. I believe this is only for shortening your code. I'm not sure if it changes the performance of the script. For example, these two mean the same thing and both compile fine in AutoIt If $var = 1 Then Return True If $var = 1 Then Return True EndIf If the statement moves on to more than one line of code, then you cannot place it all on the same line and you must use EndIf. If $var = 1 Then $var = 0 Return True EndIf The following will give you a syntax error: If $var = 1 Then Return True EndIf Edited October 8, 2009 by Vakari
pascal Posted October 9, 2009 Author Posted October 9, 2009 Well, it doesn't want to compile again, I've only done little changes Func RegUninstallStringFind($szFind) Local $index, $subkey, $sRet, $sBuff Local Const $HKLM_UNINSTALL = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $sRet = "" $index = 1 While 1 $subkey = RegEnumKey($HKLM_UNINSTALL, $index) If @error Then ExitLoop EndIf $sBuff = RegRead($HKLM_UNINSTALL & "\" & $subkey, "DisplayName") If StringInStr($sBuff, $szFind) Then $sRet = RegRead($HKLM_UNINSTALL & "\" & $subkey, "UninstallString") ExitLoop EndIf $index = $index + 1 WEnd Return $sRet EndFunc ;==>RegUninstallStringFind $a = "" ; change the search string accordingly $a = RegUninstallStringFind("Symantec AntiVirus") If $a <> "" Then Local $cmd $cmd = StringReplace( $a, "/I", "/norestart /qn /x" ) $cmd &= " REMOVE=ALL" ; this is just a test line to make sure it works MsgBox(0, "", "This is your uninstall command:" & $cmd) EndIf I can't play longer with AutoIt, it seems there are a real problem and I can't work without error messages. In my mind, there is no professionnal issue with AutoIt Don't mind about me, I'm rewriting script in Perl, I can't spend more time, my consumer waiting for application deploy. Thanks for all your replies. AutoIt is on a good way, but no enough improve like Perl, OCaml, Lisp or VB, which are used from long time.
PsaltyDS Posted October 9, 2009 Posted October 9, 2009 On 10/9/2009 at 8:15 AM, 'pascal said: Well, it doesn't want to compile again, I've only done little changes Func RegUninstallStringFind($szFind) Local $index, $subkey, $sRet, $sBuff Local Const $HKLM_UNINSTALL = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $sRet = "" $index = 1 While 1 $subkey = RegEnumKey($HKLM_UNINSTALL, $index) If @error Then ExitLoop EndIf $sBuff = RegRead($HKLM_UNINSTALL & "\" & $subkey, "DisplayName") If StringInStr($sBuff, $szFind) Then $sRet = RegRead($HKLM_UNINSTALL & "\" & $subkey, "UninstallString") ExitLoop EndIf $index = $index + 1 WEnd Return $sRet EndFunc ;==>RegUninstallStringFind $a = "" ; change the search string accordingly $a = RegUninstallStringFind("Symantec AntiVirus") If $a <> "" Then Local $cmd $cmd = StringReplace( $a, "/I", "/norestart /qn /x" ) $cmd &= " REMOVE=ALL" ; this is just a test line to make sure it works MsgBox(0, "", "This is your uninstall command:" & $cmd) EndIf I can't play longer with AutoIt, it seems there are a real problem and I can't work without error messages. In my mind, there is no professionnal issue with AutoIt Don't mind about me, I'm rewriting script in Perl, I can't spend more time, my consumer waiting for application deploy. Thanks for all your replies. AutoIt is on a good way, but no enough improve like Perl, OCaml, Lisp or VB, which are used from long time. No one has yet reproduced your symptoms with the code you have posted. It's not AutoIt, just your broken AutoIt install or Windows environment. I doubt Perl works any better with a broken install... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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