Sign in to follow this  
Followers 0
Groumphy

Enumerating *.EXE

17 posts in this topic

Hello,

In the first time my excuses for my English.

I speak only French and Dutch. :lol:

I try to use AutoIT to create a textual file including all the software installed on a computer.

But... There is always one but. :ph34r:

I do not know how to take to me there! :(

Here are the steps :

1 - To create a .TXT file (with _FileCreate), however I have each time an error saying that the function is unknown !

2 - To find all the software installed on the PC. (with FileFindNextFile ( $search ) ??).

3 - To write in the textual file (line by line) all the found software. (To have opened the textual file beforehand [with FileOpen mode 2]).

Could somebody it help me to assemble all that ?

In advance I thank you with all...

Kinds regards,

-G-roumphy


----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites



You wanted AutoIt to do it, so I'm just putting this in as a suggestion...

runwait("cmd /c dir /b C:\*.exe /s > c:\someTextFile.txt","",@SW_HIDE)

...maybe...

Share this post


Link to post
Share on other sites

Hi,

so easily! Waw.

But true !

Here is my code :

runwait("cmd /c dir /b C:\*.exe /s > c:\beer_FINDER.txt","",@SW_HIDE)
Dim $i
$i = MsgBox(4 + 32, "beer_FINDER - beta 1 :", "Désirez-vous incorporer une identification système dans le fichier beer_FINDER.txt ?")
    If $i = 6 then
  $file = FileOpen("c:\beer_FINDER.txt", 1)
  FileWriteLine($file, "*******************************************" & @CRLF)
  FileWriteLine($file, "*******************************************" & @CRLF)
  FileWriteLine($file, "*******************************************" & @CRLF)
  FileWriteLine($file, "Adresse IP: " & @IPAddress1)
  FileWriteLine($file, "Nom d'ordinateur : " & @ComputerName)
  FileWriteLine($file, "Nom d'utilisateur : " & @UserName)
  FileWriteLine($file, "*******************************************" & @CRLF)
  FileWriteLine($file, "*******************************************" & @CRLF)
  FileWriteLine($file, "*******************************************" & @CRLF)
  FileClose($file)
  MsgBox(0 + 64, "beer_FINDER - beta 1 :", "Insertion des données terminées. Fin de programme")
    ElseIf $i = 7 then
  MsgBox(0 + 64, "beer_FINDER - beta 1 :", "Pas d'action demandée par l'utilisateur. Fin de programme")
  Exit
    Else
  Exit
    EndIf

Thanks for your help.

If I need the version of the software... Can I use VER for next COMMAND ?

Or FileGetVersion ( "filename" ) is better ? But if I use FileGetVersion, I much say "each line of the beer_FINDER.txt are variant ?".

For Each line in the texte file, "write line gilegetversion($theVariant)" ...

Thanks for you advise !


----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I thinks the correct code is :

While 1
    $line = FileReadLine($file); If file = beer_FINDER.txt
    If @error = -1 Then ExitLoop
    FileWriteLine(FileGetVersion($line))
Wend

Thanks

Edited by Groumphy

----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites

Houston ?

I've a problem :

; *****************************************************
; Détection de l'OS et attribution de la commande.
; *****************************************************
Dim $OS, $C
$OS = @OSType
If $OS = "WIN32_NT" then
    $C = "cmd"
ElseIf $OS = "WIN32_WINDOWS" then
    $C = "command"
Else
    MsgBox(0 + 32, "beer_FINDER - beta 2", "Erreur : le système d'exploitation n'a pas été détecté.")
EndIf
; *****************************************************
; Déclaration du fichier de lecture
; *****************************************************
Dim $F, $L
$F = FileOpen("folders.txt", 0)
If $F = -1 then
    MsgBox(0 + 32, "beer_FINDER - beta 2", "Erreur : Le fichier n'a pas pu être ouvert pour lecture.")
    Exit
ElseIf $F = 0 then
; *****************************************************
; Déclaration des commutateurs
; ***************************************************** 
; -----------------------------------------------------
    While 1
    $L = FileReadLine($F)
    If @ERROR = -1 then
  MsgBox(0 + 32, "beer_FINDER - beta 2", "Fin du loop") 
  ExitLoop
    Else
    ; -----------------------------------------------------
  Dim $CL, $U
  $CL = MsgBox(4 + 64, "beer_FINDER - beta 2", "Désirez-vous scanner les sous-répertoires des dossiers mentionnés dans FOLDER.TXT ?")
  If $CL = 6 then
     $U = " /s"
  ElseIf $CL = 7 then
     $U = ""
  Else
     $U = " /s"
  EndIf
    ; -----------------------------------------------------
  Dim $Z
  $Z = @IPAddress1
    ; -----------------------------------------------------
    ; *****************************************************
    ; Ligne de commande MS-DOS
    ; ***************************************************** 
  runwait($C & " /c dir /d /n" & $L & "*.exe" & $U &" > C:\" & $Z & $L & ".beer_FINDER","",@SW_HIDE)
    EndIf
    Wend
Else
    MsgBox(0 + 32, "beer_FINDER - beta 2", "Erreur inconnue. Numéro Erreur : 2")
EndIf

Why this script doesn't walk ?

Good question or ... I'm stupid ?!


----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I looked at your code.

I cleaned it up, you can find it at the bottom.

What I noticed is: you didn't put a space after /n in your runwait.

Can you tell us where it goes wrong?

And when you're testing, you can leave @SW_HIDE out.

Good luck.

; *****************************************************
; Détection de l'OS et attribution de la commande.
; *****************************************************
Dim $OS, $C
$OS = @OSType
If $OS = "WIN32_NT" then
    $C = "cmd"
ElseIf $OS = "WIN32_WINDOWS" then
    $C = "command"
Else
    MsgBox(0 + 32, "beer_FINDER - beta 2", "Erreur : le système d'exploitation n'a pas été détecté.")
EndIf

; *****************************************************
; Déclaration du fichier de lecture
; *****************************************************
Dim $F, $L
$F = FileOpen("folders.txt", 0)
If $F = -1 then
    MsgBox(0 + 32, "beer_FINDER - beta 2", "Erreur : Le fichier n'a pas pu être ouvert pour lecture.")
    Exit
EndIf

; *****************************************************
; Déclaration des commutateurs
; ***************************************************** 
; -----------------------------------------------------
While 1
$L = FileReadLine($F)

If @ERROR = -1 then
    MsgBox(0 + 32, "beer_FINDER - beta 2", "Fin du loop") 
    ExitLoop
EndIf

; -----------------------------------------------------
 Dim $CL, $U
 $CL = MsgBox(4 + 64, "beer_FINDER - beta 2", "Désirez-vous scanner les sous-répertoires des dossiers mentionnés dans FOLDER.TXT ?")
 If $CL = 7 then
  $U = ""
 Else
  $U = " /s"
 EndIf
; -----------------------------------------------------
 Dim $Z
 $Z = @IPAddress1
; -----------------------------------------------------
; *****************************************************
; Ligne de commande MS-DOS
; ***************************************************** 
 runwait($C & " /c dir /d /n " & $L & "*.exe" & $U & " > C:\" & $Z & $L & ".beer_FINDER","",@SW_HIDE)

Wend
Edited by SlimShady

Share this post


Link to post
Share on other sites

Hello,

Thank you for your opinion and your assistance.

I tested script that you provided me, but I did not have any results.

I changed the following line:

runwait($C & " /c dir /d /n " & $L & "*.exe" & $U & " > C:\" & $Z & $L & ".beer_FINDER","",@SW_HIDE)

by :

runwait($C & " /c dir /d /n " & $L & "*.exe" & $U & " > C:\beer_FINDER.txt","",@SW_HIDE)

and the result was correct.

The problem came owing to the fact that a file name cannot start with a number.

I tested this script under Windows XP but not yet under Windows 98.

I would provide you complete script as soon as all functions. With soon,

Groumphy


----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites

one thing, you're reinventing the wheel with this section of code.

$OS = @OSType
If $OS = "WIN32_NT" then
   $C = "cmd"
ElseIf $OS = "WIN32_WINDOWS" then
   $C = "command"

just use @comspec, it already does what you're doing. maybe to save some time, just change it to

$c = @comspec

anyways. just noticed that...


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Hello,

Thank you for the easy way, I had not thought of this type of order. :ph34r:

However that does not work on Windows 98 or Windows 95! It indicates to me that it cannot send the order...

But "command.com" is correct via Run... If I type DIR /?, all the parameters are well included/understood... I do not know any more...

:(


----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

sorry, I've verry carefully ensured that I no longer have contact with Win95/98 machines, so I'm afraid I can't test this one out...

but, now I'm curious... so, what should be in folders.txt? I can't test this without that...

so, what's $z and $l ? do they need a space in between them?

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

ok, while I have no idea what $l might be but, if it or anything else that makes up a filename has spaces or special characters in it, the command line needs to see double quotes around it.

I believe this code will do that, and might fix it.

RunWait(@comspec & " /c dir /d /n " & $l & "*.exe" & $u & " > " & '"C:\' & $z & $l & '.beer_FINDER"', "", @SW_HIDE)

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Hello,

I tested the solution given by the line of order above and the result does not give any more a mistake in interpretation of script but when I scan on Windows 95/98, the file is of contained !

:ph34r::(

I also added a log (at the end of the name) for not to crush the file if the textual file contains several line of scan and a difference of textual file for the operating systems

My code :

; beer_FINDER beta 2
; by Groumphy. Special thanks to AutoIT Team.

Dim $C
$C = @ComSpec

Dim $F, $L

Dim $OS, $I
Dim $OS = @OSType
If $OS = "WIN32_NT" then
    $I = "foldNT.txt"
ElseIf $OS = "WIN32_WINDOWS" then
    $I = "fold32.txt"
Else
    MsgBox(0 + 16, "beer_FINDER - beta 2", "Erreur : Identification du système incorrect")
EndIF
 
$F = FileOpen($I, 0)
If $F = -1 then
   MsgBox(0 + 32, "beer_FINDER - beta 2", "Erreur : Le fichier n'a pas pu être ouvert pour lecture.")
   Exit
EndIf

While 1
$L = FileReadLine($F)

If @ERROR = -1 then
   MsgBox(0 + 32, "beer_FINDER - beta 2", "Fin du scannage. Les fichiers sont extrait sur la disquette.") 
   ExitLoop
EndIf

Dim $CL, $U
$CL = MsgBox(4 + 64, "beer_FINDER - beta 2", "Désirez-vous scanner les sous-répertoires des dossiers mentionnés dans FOLDER.TXT ?")
If $CL = 7 then
 $U = ""
Else
 $U = " /s"
EndIf

Dim $Z
$Z = @IPAddress1

Dim $T
$T = @SEC

RunWait(@comspec & " /c dir /d /n " & $l & "*.exe" & $u & " > " & '"A:\' & $z & "xxx" & $T & '.txt"', "", @SW_HIDE)

Wend

foldNT.txt contain :

C:\
C:\WINNT\

fold32.txt :

C:\
C:\WINDOWS\

----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites

Hello,

I tested the solution given by the line of order above and the result does not give any more a mistake in interpretation of script but when I scan on Windows 95/98, the file is of contained !

:ph34r:  :(

I also added a log (at the end of the name) for not to crush the file if the textual file contains several line of scan and a difference of textual file for the operating systems

I'm sorry, I really don't understand. Is it broken? Where's it broken? What is happening on 95/98?

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Groumphy:

RunWait(@comspec & " /c dir /d /n ..."

Ther is no /d and /n Option in DIR on Win95/98

arctor

Share this post


Link to post
Share on other sites

Thanks, I try again with new script line and post again if matter is.

Thanks,

Groumphy


----------------------GroumphyMore information about me [Fr]

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Hi,

It's OK.

Thanks for your help.

With kind regards,

Groumphy

Edited by Groumphy

----------------------GroumphyMore information about me [Fr]

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