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.

IUIAutomation - Topic with framework and examples

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

    • Earthshine
      By Earthshine
      This baby can do almost any language! I found Gleany on this site and set it up on a fresh win10 install. all i would need to do to make it build an exe of the search files app we discovered is the .NET Target Framework download to build 100 % but the exe works and generates! You also need to add the path the the version of csc.exe that you want to run. MSBuild is part of .NET and can read your .csproj file.
      YOU can develop .NET OR C/C++ on this baby!
      Super lightweight (fit for crappy laptops), and you can use any dev compilers you wish, Ming, MS, etc, whatever.
      To use the build, you need to open the csproj file, else, to check your syntax it can compile individual files as well. The warning are because I do not have the .NET 4.6 Targeting Pack installed... LOL, and I could get rid of the Core warning, yes, I did not want to build a .NET Core.dll I wanted a live x64 exe! Told you MSBUILD could handle .CSPROJ, .VBPROJ, and all others Microsoft. Don't let Visual Code or Visual Studio slow you down, although, this works with Visual Code as well but there is only debugging in CORE.DLL projects

      ListFiles Example.zip
       

    • RC86
      By RC86
      Afternoon!
      Just a quick one as this has dawned on me recently when creating a little program.  When calling an executable I've created like Run(otherapp.exe) from within my executable is there a best practice to ensure things have gone smoothly?  So for example, should I monitor the PID to ensure it runs and closes within an acceptable timeframe?  Or within my other executable should I do EXITs in a certain way after functions and return codes etc?
      Could be a silly question but thought I'd ask.
    • Eggsplorer
      By Eggsplorer
      Hi,
      Ich hab ein Script für Windows Updates, dass nach dem OOBE aufgerufen werden soll. Run/RunOnce ist daher nicht möglich.
      Stattdessen möchte ich das Script in den Autostart schreiben lasse. Wenn die OOBE beendet wird und der Administrator angemeldet wird, soll das Update-Script einmalig aufgerufen werden und sich anschl. selbst löschen.
      Lang rede, kurzer Sinn:
      Wie kann ich folgendes Script in den Autostart schreiben?
      RunWait(@ComSpec & " /c " & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\UA\Scripts\win-updates.ps1 -MaxUpdatesPerCycle 100 -RestartRequired 1", "") Ich würde ungern eine BAT oder EXE reinkopieren, da ich es unsauber finde. Die müsste ja auch zusätzlich irgendwo liegen.
      Danke
      Eggsplorer
    • 9252Survive
      By 9252Survive
      Hello Guys, 
      Is there a way to have Auto it Exe messages/line number when you hover over the tray icon just at it shows when you run Au3.?
      For an example, if I the script has paused due to WinWait or Sleep I could hover over the icon and it shows the line where it's at. Is there a way to achieve the same with the compiled exe? 
      Many thanks for the help! 
       
    • 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