Jump to content

Variable problems

Recommended Posts

I have 2 copies of the same script, each in their own folder. They are set up to pull the settings for the variables from a settings.ini file located in the same directory as the script. After the first one is done running, it is set up to automatically start up the second script which will use a totally different set of settings defined in it's own settings.ini file. When run individully, they run 100% fine. The first one does what it is suposed to, and so does the second one. The problem is when I enable it so that the first one starts the second when it is done. When that is enabled, the first one runs flawlessly, but then the second one starts running and for some reason, instead of getting it's settings from the settings.ini file in it's folder, it gets it from the first one's folder. I spent 5 hours yesterday searching for my problem, and I couldn't find anything. I think the bug might be in Autoit. I will try to post an example script when I get home.

Link to post
Share on other sites

Put the following line at the beginning of each script:

MsgBox(4096,"Debug", "The working directory is " & @CRLF & @WorkingDir)

My hunch is that you are not explicitly setting the working directory in your script. Then, when C:\folderOne\scriptOne.au3 calls the following, scriptTwo.au3 is still going to going to use C:\folderOne as the "current working directory"

Run(@AutoItExe & " " & "C:\folderTwo\scriptTwo.au3")

I don't think this is an AutoIt bug; I think it's a Windows feature.

There are two solutions:

FileChangeDir(@ScriptDir) ;before you call iniRead in second script

The other is to use

IniRead(@ScriptDir & "\nameofIniFile.ini") ;an alternative

Hope this helps

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to post
Share on other sites

well, you were right, I stuck that debug line in there and when the second one started up, it was using the folder from the first one. Thanks so much. I was getting really frustrated there. As far as I can see, FileChangeDir(@ScriptDir) fixed it. Stupid windows and their "features" :lmao: Too bad windows isn't open source, i'd have a few modifications to make if it was.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...