Sign in to follow this  
Followers 0
pascal

I'm going crazy

15 posts in this topic

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 ?

Share this post


Link to post
Share on other sites



Two problems:

1. I think you are missing an EndIF on the If @error line.

2. @error is not a boolean.

Share this post


Link to post
Share on other sites

and another... StringInStr returns a position (integer), not a boolean

Share this post


Link to post
Share on other sites

I know a Featured doctor :)


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

No errors in the Compiling

Try Compiling From SciTE Script Editor

Tools ===> Build

Will come later :)


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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 :P

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

Share this post


Link to post
Share on other sites

and another... StringInStr returns a position (integer), not a boolean

Yes, correct information

But the logic operation is also correct

Failure: Returns 0 / False

Success: Returns the position of the substring

position Starts from one to infinity / True


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Edit: Looks like PsaltyDS beat me to it :)

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 by Vakari

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

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