Sign in to follow this  
Followers 0
maarten

Reading installed software

5 posts in this topic

#1 ·  Posted (edited)

Hi there verybody.

I just found autoit and i am loving it.

but i have a lot to learn.

I am trying to read the installed software from a computer.

I wrote the following script but in some cases is displays a sid instead of the displayname inside the sid.

Can anybody help me? What is need is that it reads all installed software and write the display name of the software in an txt file.

I got it to work that it writes the installed software but not the displayname.

or it writes all installed software with the same display name everywhere.

Thanks for you help or input in advanced.

Maarten

#include <File.au3>

_FileCreate ("c:\regestry\test.txt")

;test if file can be opend

$file = FileOpen("c:\regestry\test.txt", 1)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

For $i= 1 to 50

$file = FileOpen("c:\regestry\test.txt", 1)

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", $i)

;$varr = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", "DisplayName", $i)

$varrr = $var ;& $varr

If @error <> 0 then ExitLoop

FileWrite($file, $varrr & @CRLF)

fileclose($file)

Next

Edited by maarten

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This might help a bit.

Your RegRead was evaluating the $i variable, rather than the returned $var result of the key name. I've tidied up this code a little too.

You shouldn't need #include <File.au3>.

$filename="d:\testreg.txt"
$file = FileOpen($filename, 1)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

$regItem="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

For $i= 1 to 50
  $var = RegEnumKey($regItem, $i)
  $varr = RegRead($regItem & $var & "\", "DisplayName")
  If @error <> 0 then ExitLoop
  FileWriteLine($file, $var & $varr & @CRLF)
Next

fileclose($file)
Edited by MrBeatnik

Please correct me if I am wrong in any of my posts. I like learning from my mistakes too.

Share this post


Link to post
Share on other sites

I think the @error is in the wrong place?

Try this out:

#include <File.au3>

$file = "c:\testreg.txt"

If Not FileExists($file) Then
    _FileCreate("c:\testreg.txt")
EndIf

FileOpen($file, 2)  ;erases file for new contents

$regItem = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

$i = 0
While 1
    $i += 1
    $var = RegEnumKey($regItem, $i)
    If @error Then ExitLoop
    $varr = RegRead($regItem & $var & "\", "DisplayName")
    FileWriteLine($file, 'Key Name:  ' & $var & @CRLF & 'Display Name:  ' & $varr & @CRLF & @CRLF)
WEnd

FileClose($file)

Share this post


Link to post
Share on other sites

Thank you all for you repleys'

The second code is the best one that works the best for me.

Many thanks.

Any tips on what kind of books i schould read ?

Maarten

Share this post


Link to post
Share on other sites

Thank you all for you repleys'

The second code is the best one that works the best for me.

Many thanks.

Any tips on what kind of books i schould read ?

Maarten

http://www.autoitscript.com/forum/index.php?showtopic=20406 --> more advanced version of your script :lmao: Might give you a lot of tips how things works :ph34r:


My little company: Evotec (PL version: Evotec)

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