Sign in to follow this  
Followers 0
TerrorByter

Executing an exe with multiple path and file name vairables

4 posts in this topic

#1 ·  Posted (edited)

Hi, Im very very new to scripting, and this forum aswell, so forgive me if Ive posted this on the wrong section.

Also, Ive searched this forum including google, for a method to my problem, but was unable to find much.

Ill explain, what Im trying to do, and hopfully one of you would be able to tell me if Autoit can achieve this, and how I might go about it.

Im trying to create a script, that will launch an exe that has multiple path variables, and preform some mouse clicks, and some key sends.

I have the mouse clicks and keysends worked out and no problem there... however the part of locating the right file to execute escapes me.

This is what Im trying to achive...

The script needs to execute the specified exe, which might be in different locations, and the file itself might have two different names.

In my personal case the file to execute is "C:Program Files (x86)AuzentechX-Fi Forte 7.1Console LauncherAZMSu.exe"

On another computer this first path variable, could be "C:Program Files" or "C:Program Files (x86)"

The second path variable could be "Auzentech" or "Creative"

The third path variable could be X-fi Forte 7.1 or an unknown directory (will vary depending on sound card model)

The forth path will always be the same "Console Launcher"

The file name variable could be either "AZMSu.exe" or "MdSwtchu.exe”

Forgve my lack of know how, but would something like this be possible with autoit script, or any other scripting language for that matter?

if so, would anyone be able to direct me to a guide of sorts that I may read up on how to achieve this?

Edited by TerrorByter

Share this post


Link to post
Share on other sites



Ive solved my own problem by reading the path values from the registry... sorry if I gave anyone headaches by thinking about this :D

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Good idea looking in the reg for it.

Already wrote a solution. I'll post it anyway, so I don't feel like I totally wasted the last 10 minutes of my life..

Local $sExe = FindSoundCardExe('Auzentech', 'Creative', 'Console Launcher', 'AZMSu.exe', 'MdSwtchu.exe')
If $sExe Then MsgBox(64,'Success','The full path to the file is:' & @CRLF & $sExe)

Func FindSoundCardExe($sBrand1, $sBrand2, $sLauncherdir, $sExe1, $sExe2)
    Local $sPath
    If @AutoItX64 Then
        $sPath = @ProgramFilesDir & ' (x86)'
    Else
        $sPath = @ProgramFilesDir & ''
    EndIf
    If FileExists($sPath & $sBrand1) Then
        $sPath &= $sBrand1 & ''
    ElseIf FileExists($sPath & $sBrand2) Then
        $sPath &= $sBrand2 & ''
    Else
        MsgBox(16,'Failure','Error - No directory named ' & $sBrand1 & ' or ' & $sBrand2 & ' exists in ' & $sPath)
        Return
    EndIf
    Return ReturnFileName(FindLauncherDir($sPath, $sLauncherdir), $sExe1, $sExe2)
EndFunc
Func FindLauncherDir($sPath, $sLauncherdir)
    Local $hFound, $sSub
    $hFound = FileFindFirstFile($sPath & '*')
    If $hFound <> -1 Then
        While 1
            $sSub = FileFindNextFile($hFound)
            If @error Then ExitLoop
            If @extended Then
                If FileExists($sPath & $sSub & '' & $sLauncherdir) Then
                    FileClose($hFound)
                    Return $sPath & $sSub & '' & $sLauncherdir & ''
                EndIf
            EndIf
        WEnd
    EndIf
    MsgBox(16,'Failure','Error - Unable to locate a directory named ' & $sLauncherdir)
    FileClose($hFound)
EndFunc
Func ReturnFileName($sPath, $sExe1, $sExe2)
    If Not $sPath Then Return
    If FileExists($sPath & $sExe1) Then
        Return $sPath & $sExe1
    ElseIf FileExists($sPath & $sExe2) Then
        Return $sPath & $sExe2
    Else
        MsgBox(16,'Failure','Error - Unable to locate the file either file ' & $sExe1 & ' or ' & $sExe2 & ' in the directory ' & $sPath)
    EndIf
EndFunc
Edited by Quual

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

yes... lol... thats what I ended up doing... is looking for it in the registry. Although I took a more direct approach by looking in "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Paths"

and just two possible file names. Luckily these entries are registered during installation of these apps.

This is what I did...

$varreg1 = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp PathsAZMSu.exe"
$varreg2 = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp PathsMdSwtchu.exe"
$varapp1 = "Mode Switcher"
$varclass1 = "[CLASS:CTModeSwitcherClass]"
$vartray1 = "X-Fi Mode Change"
If $CmdLine[0] = 0 Then Exit
If $CmdLine[1] = "/ent" Then
Local $var1 = RegRead($varreg1, "")
Local $var2 = RegRead($varreg2, "")
Run ($var1)
Run ($var2)
WinActivate ($varapp1)
WinWaitActive($varapp1)
ControlClick ($varclass1, "", 24001, "primary", 2, "", "")
TrayTip($vartray1, "Entertainment Mode", 3, 0)
Sleep(7000)
EndIf

Thanks for your effort though... I probably would have gone with your solution if I didnt come up with mine :D

Edited by TerrorByter

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