Sign in to follow this  
Followers 0
ROSharps

Path Dilemma

4 posts in this topic

Hi,

I have been using autoit for close to a month, and I have to admit it is really nice because it gives freedom to what other programing programs can offer and I have been able to get most of the things that I needed working correctly. Recently I have been working on a master program that runs other small scrips located in different folders. What I am trying to achieve is to run a few scripts from a shared network drive with a master program that encorporated a lot of small scripts. The question that I have is if there is a set path command or method for autoit that would set the local path to a different location than the master file. For example, I have the master file on a shared drive at \\drive\folder\masterscript.exe . The master file then opens small scripts located at \\drive\folder\scripts\script1.exe . script 1 opens a script that downloads a file fromt the internet to a set location \\drive\folder\scripts\script1files and also runs it.

The code in the masterscript is similar to

Run("scripts\script1.exe")

The code in the script1 file is similar to

Run("script1files\filename.exe")

If I run the script1 manually, it works fine since it picks up the local path as being the folder that the script1 is located in.

If I run the masterprogram script1 opens correctly, but it will not open the path for the following program correctly. In other words it will not open filename.exe because the local path is now different at folder\scripts\...

The reason I am avoiding using a full path is because the files may need to be run from a mapped drive with a random drive letter, the script may be needed to be run independently, or the masterprogram may need to be used to run all other scripts. What I would like to find is a method to set the local path to each location of the script. In other words if I use the master program to open the scripts I would like to set the local path of each individual script to the location of the scripts and not the masterprogram path. I am unable to use the full path to the master program because then the individual script will not run correctly, and the program that I am using the script for also has its own directory structure starting where the program is located which I am unable to change.

I know this sounds a little confusion, but it is the only way I can see to explain the dilemma I have stumbled upon.

Thank you for the support

Share this post


Link to post
Share on other sites



Hi ROSharps,

First, you can use relative path names like Run("../folder1/script.exe").

Second, you can set the workingdir in the Run command: Run ( "program" [, "workingdir" [, show_flag[, opt_flag ]]] )

Third, you can use FileChangeDir() To set the current working directory.

Hope that helped you. :huh2:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Hi Hannes

Thank you so much for the help this definetly helps out solve a lot of the issues that I have. I still have some issues with the path and I am not sure if maybe I am coding it incorectly. Let me break down some more information of my setup. Right now I have a C# application that uses a combobox with a drop down menu to select the individual scripts. The main c# application is located in \\wt\application\wt.exe . The individual scripts are then located in a seperate folder at \\wt\application\scripts\winrepair\script1.exe . Script1.exe will open a file from \\wt\application\scripts\winrepair\script1files\registrymod.exe .

I have added the FileChangeDir("Script1Files") and a msgbox(0,"",@WorkingDir) to see what the working directory reads as. If I run the script directly the directory reads \\wt\application\scripts\winrepair\script1files which is correct, but if I run the script using the C# application it read the directory as \\wt\application . It still opens the script file and the msgbox comes up, but it will not run the registrymod.exe because the working directory is not changing to the working directory of the script rather than the c# application. Can you point me in the right direction as to why it is not changing the working directory correctly? I cant use the relative path because someone may want to copy the script to a hdd and run it so to make it usable in other locations. I have also tryed changing the directory when running just the program, but the registrymod uses a database which has to be inside of the same folder and therefore it does not work with changing the working directory using the run()

Thanks again

Hi ROSharps,

First, you can use relative path names like Run("../folder1/script.exe").

Second, you can set the workingdir in the Run command: Run ( "program" [, "workingdir" [, show_flag[, opt_flag ]]] )

Third, you can use FileChangeDir() To set the current working directory.

Hope that helped you. :huh2:

Share this post


Link to post
Share on other sites

Hi ROSharps,

did you try calling

FileChangeDir(@ScriptDir) at the beginning of your script?

@ScriptDir is a built in Macro that will return the path to the exe or au3 file you're running.

Sorry for the late answer. You probably already found out. :huh2:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

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