ur

Need to find the path of exe

8 posts in this topic

I have an exe with name "erwin Data Modeler r9.7 (32-bit)_2332.exe"

 

THe lat 4 digits 2332 may vary and also the version number r9.7 also might vary.

So, how to write a generic expression so that the exe can be picked from the current directory {with any version (9.7 or anything) and any build number (2332 or anything)}

 

Thanks in Advance

Share this post


Link to post
Share on other sites



Use:
StringInStr ( "string", "substring" [, casesense = 0 [, occurrence = 1 [, start = 1 [, count]]]] )
 

Kind Regards, Starf0x

Share this post


Link to post
Share on other sites
10 minutes ago, Starf0x said:

Use:
StringInStr ( "string", "substring" [, casesense = 0 [, occurrence = 1 [, start = 1 [, count]]]] )
 

Kind Regards, Starf0x

But this we can find only one substring right.But the 32 number is fixed above.

I forgot to mention above, if it is 64 instead of 32 then the exe should not be picked.

Share this post


Link to post
Share on other sites

Think about this, you said the last digits are different the rest is the same: " erwin Data Modeler"
So do a check to see if that piece of text exists, and then you have the filename.

 

Share this post


Link to post
Share on other sites

I need to check one more thins whether  32-bit  or 64-bit..Can you suggest.

Share this post


Link to post
Share on other sites

Got it, Thanks @Starf0x

Func GetFileList($dir)
    ; List all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray($dir, "*")
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
    ; Display the results returned by _FileListToArray.
    ;_ArrayDisplay($aFileList, "$aFileList")

    For $vElement In $aFileList
        if StringInStr($vElement, "erwin Data Modeler")>0 and StringInStr($vElement, "32-bit")>0 Then
            return $vElement
        EndIf
    Next
    return "0"

EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites

You're welcome.
Thanks for sharing so others also have a chance for an solution.

Cheers, Starf0x

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

EX: Flash Player 24.0.0.194.exe

Local $search = FileFindFirstFile("Flash Player*.exe")
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
Else
    Local $file = FileFindNextFile($search)
    $Exe = @ScriptDir & '\' & $file
    ShellExecuteWait($Exe, '-install')
    MsgBox(64, 'FlashPlayer', 'Complete!')
EndIf

This is what i use to install flash player, only the numbers after this change, so this works every time.

I guess for you you could use
 

FileFindFirstFile("erwin Data Modeler*.exe")

StringInStr($vElement, "32-bit")>0 Then

 

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

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

  • Similar Content

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning AutoIt community!
      Today, I'm here to ask you if you know how to run an .exe from cmd.exe ( Command Prompt )...
      My intention is to read a .ini file where I store an information that has to be included in the shell, and run an .exe with that information...
      I'll give you an example
      Local $aFileCartellaAuditCopy = _FileListToArray($sPercorsoAuditCopy, "*.txt") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante la lettura della lista dei file nella directory" & @CRLF & $sPercorsoAuditCopy & @CRLF & "Errore: " & @error) Return False Else Local $iPID = Run("cmd.exe" & ' /k "C:\Users\Portatile-60\Desktop\HmiCheckLogIntegrity.exe" "C:\Users\Portatile-60\Desktop\AuditTrailDosaggio0_20170327_151335_DOSAGGIO_PW_01.txt"') ; & " /k " & '"' & $sHmiCheckLogIntegrity & '"' & " " & '"' & $sPercorsoAuditCopy & "\" & $aFileCartellaAuditCopy[1] & '"', "", @SW_SHOW, $STDOUT_CHILD) Return True EndIf This code is in a function, that returns False if it can retrive at least a file from the path stored in the .ini file...
      Else
      I would like to run the Command Prompt with the .exe and with a parameter of that .exe, but it seems to not work properly.

      Could please anyone tell me why?

      Thanks  
    • Kyan
      By Kyan
      Hey everyone
      I'm stuck with this regular expression, for matching a iso standard version
      what I want to do is match the text in green: ISO 11784:1996/Amd.2:2010(E)
      there is also others that look like this: ISO 11789:1999(E), and without the (E) part,
      Só I did this one
       (?i)ISO.+?[\d-]+:(?:\d+/Amd.+?:)?[\d-]+(?:\(\w\))* to match both cases but doesn't ignore the text in red
      Can somebody point out what I'm doing wrong here?
       
    • Reizvoller
      By Reizvoller
      Howdy!
      I am trying to do something a little whacky but here's the function that's kicking back an error.
      I am fairly sure I am overlooking a simple error but I am not seeing it.
      Func mouseSpot () Global $mouseSpot = MouseGetPos() ConsoleWrite ($mouseSpot[0] & ", " & $mouseSpot[1] & @CRLF) FileWriteLine ("mouseGrabs.txt" , "MouseClick ('"'primary'"' , $mouseSpot[0] , $mouseSpot[1], 1, 10)" ) EndFunc The error displays as this 
      Any thoughts?
      Thanks!
      -Reiz
    • richtburkhart
      By richtburkhart
      I'm getting the syntax error: "Statement cannot be just an expression."
      Here's the piece of code where it occurs:
      $Check = WinExists("MySQL Installer") If $Check <> "" Then WinClose("MySQL Installer") Else $Check = ControlGetHandle("", "&No", '[CLASS:Button; INSTANCE:2]') If $Check <> "" Then ControlClick("", "&No", '[CLASS:Button; INSTANCE:2]') Sleep(10000) WinClose("MySQL Installer") EndIf EndIf Anyone know why this error is occurring?