Kevinsyel Posted August 7, 2013 Share Posted August 7, 2013 So I've been using AutoIT for years now, but there's something that's always puzzles me: How come @workingDir, or even the "workingDir" variable of ShellExecute (to name one function), NEVER work? For example, I can call a FileChangeDir("C:Not_My_Script_Dir") to any directory, and then immediately after calling, output @workingDir, and it will always be the same as @scriptDir. Or I have an application that only works within it's directory (say if I'm making a call to a powershell script) and I pass the directory of a script into ShellExecute so I have something like ShellExecute("powershell", ".script.ps1", "C:Not_My_Script_Dir") What's blocking this from working? I'd love for some help. Thanks. Link to comment Share on other sites More sharing options...
kylomas Posted August 7, 2013 Share Posted August 7, 2013 kevinsyel, Run the following: ConsoleWrite(@workingdir & @LF) dircreate(@scriptdir & '\test') filechangedir(@scriptdir & '\test') ConsoleWrite(@WorkingDir & @LF) Some functions, FileOpenDilaog for example, also set the current working directory. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Kevinsyel Posted August 7, 2013 Author Share Posted August 7, 2013 Here's what I have that's causing issues: $installArray[$i][1] = @ScriptDir & "\" & $installArray[$i][1] $tempStringAr = StringSplit($installArray[$i][1], "\") $workingDir = $tempStringAr[1] For $j = 2 to $tempStringAr[0] - 1 $workingDir = $workingDir & "\" & $tempStringAr[$j] Next LogFile("--INFO: Working Dir is: " & $workingDir) FileChangeDir($workingDir) LogFile("--INFO: Working dir is: " & @WorkingDir) LogFile() is a function that writes to console, and to an output log. element 1 of the 2nd dimension of my 2D array is a path to an installer. I append "@scriptDir" to it, to get a full working path, and then I strip the last "" off (the .exe or .msi portion) to get the directory of the installer. I do this using a For;Next loop and iterate through each element, appending a "". Now when I print my variable "$workingDir" I get the directory I expect. I then pass it into FileChangeDir, but my @workingDir never gets changed. Your code snippet worked for me, but for some reason, my code doesn't Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now