Jump to content
Sign in to follow this  
Warmonger

Run or Shellexecute?

Recommended Posts

Warmonger

Hello all, Ive been playing around in autoit for a little while now. And I got a few questions/problems to ask.

When either "Run" or "Shellexecute" are called do they run/execute the program from the directory it is in or not? Because Im trying to get it to load a set of server files for a game and when it executes the file the server file reports back that it cannot read config.ini which is the configuration file for ip, ports, database logins etc thats in the same folder with it. Is it mandatory that I must set a workingdir for this? or?

Here is my current function:

Func Button1() ; Function When Button1 Is Clicked (Start Server)
        $var_1 = IniRead("dsm.ini", "Start", "DBMON Delay", "0") ; Set Variable For Startup Timer
        $var_2 = IniRead("dsm.ini", "Start", "CAST Delay", "0") ; Set Variable For Startup Timer
        $var_3 = IniRead("dsm.ini", "Start", "MSG Delay", "0") ; Set Variable For Startup Timer
        $var_4 = IniRead("dsm.ini", "Start", "LOGIN Delay", "0") ; Set Variable For Startup Timer
        $var_5 = IniRead("dsm.ini", "Start", "SESSION Delay", "0") ; Set Variable For Startup Timer
        $var_6 = IniRead("dsm.ini", "Start", "DBMON", "0") ; Set Variable For Loading DBMON
        $var_7 = IniRead("dsm.ini", "Start", "CAST", "0") ; Set Variable For Loading Cast Server
        $var_8 = IniRead("dsm.ini", "Start", "MSG", "0") ; Set Variable For Loading Messenger Server
        $var_9 = IniRead("dsm.ini", "Start", "LOGIN", "0") ; Set Variable For Loading Login Server
        $var_10 = IniRead("dsm.ini", "Start", "SESSION", "0") ; Set Variable For Loading Session Server
        $var_11 = IniRead("dsm.ini", "Start", "DEKARON", "0") ; Set Variable For Loading Dekaron Server
        ShellExecute($var_6)
        Sleep($var_1)
        ShellExecute($var_7)
        Sleep($var_2)
        ShellExecute($var_8)
        Sleep($var_3)
        ShellExecute($var_9)
        Sleep($var_4)
        ShellExecute($var_10)
        Sleep($var_5)
        ShellExecute($var_11)
    EndFunc
Edited by Warmonger

Share this post


Link to post
Share on other sites
BrettF

Welcome to the forums!

What would the value of $var_1 be for example?

From my understanding ShellExecute is designed more so to say, open word documents with word. Open files with a default program in other words. In your case I believe it would be better suited to use run and make sure you specify the Working directory to the folder the executable your trying to run...

Cheers,

Brett

Edited by BrettF

Share this post


Link to post
Share on other sites
Warmonger

Welcome to the forums!

What would the value of $var_1 be for example?

From my understanding ShellExecute is designed more so to say, open word documents with word. Open files with a default program in other words. In your case I believe it would be better suited to use run and make sure you specify the Working directory to the folder the executable your trying to run...

Cheers,

Brett

Thanks for the speedy reply. As for my variables i have them read from ini like so:

[Start]
DBMON = Folder\Program.exe
DBMON Delay = 10000
CAST = Folder\Program.exe
CAST Delay = 10000
MSG = Folder\Program.exe
MSG Delay = 10000
LOGIN = Folder\Program.exe
LOGIN Delay = 10000
SESSION = Folder\Program.exe
SESSION Delay = 10000
DEKARON = Folder\Program.exe

As the script executes several different programs in several different folders. Is using variables to set a workingdir allowed? like so:

$var_1 = IniRead("dsm.ini", "Start", "DBMON Delay", "0") ; Set Variable For Startup Timer
        $var_6 = IniRead("dsm.ini", "Start", "DBMON", "0") ; Set Variable For Loading DBMON
        $var_18 = IniRead("dsm.ini", "Start", "DBMON Dir", "0") ; Set Variable For DBMON Dir
        Run($var_6, $var_18)
        Sleep($var_1)

Share this post


Link to post
Share on other sites
BrettF
Warmonger

Why not get the directory from the path to the executable you're running? _PathSplit would do the job.

How would I go about doing that and keeping it compatible with letting users set their own directorys in dsm.ini? This is the first script I've wrote and I'm not too familiar with lots of these functions. Could you give me a brief idea with the info Ive provided on how to set them up properly. Also this tool doesn't have a default path as people place their server files in many different places on their computers. So how would I go about spliting up the path if say someones is C:\folder\program.exe and someone elses is C\Documents And Settings\User\Me\New Folder\Server\program.exe? Or would it be easier to set a variable and let the user define it in ini? Any input would be appreciated.

Share this post


Link to post
Share on other sites
Warmonger

$var_1 = IniRead("dsm.ini", "Start", "DBMON Delay", "0") ; Set Variable For Startup Timer
        $var_6 = IniRead("dsm.ini", "Start", "DBMON", "0") ; Set Variable For Loading DBMON
        $var_18 = IniRead("dsm.ini", "Start", "DBMON Dir", "0") ; Set Variable For DBMON Dir
        Run($var_6, $var_18)
        Sleep($var_1)

Topic solved. Used what I thought of before and worked, thanks BrettF for support.

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  

×