Karan Posted May 29, 2015 Share Posted May 29, 2015 I am trying to use the CmdLine argument from a cmd window to run the compiled exe. The argument is the file full path. (re-creating the scenario of drag and drop). The compiled script was tested in two ways. One, direct drag and drop of file onto the exe icon. and the other from a cmd window. In the compiled exe, I change the working directory using FileChangeDIr($CmdLine[1]). This works perfectly fine when I drag and drop the file onto the exe. But I call the same exe from a cmd window, the FileChangeDir does not change the working directory but maintains it to be the default working directory when cmd was opened with. Is there a way to change the working directory in autoit so that the @WorkingDir changes even when I use cmd to start the program? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 29, 2015 Developers Share Posted May 29, 2015 FileChangeDir() function before running CMD?Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Karan Posted May 29, 2015 Author Share Posted May 29, 2015 No, I open a cmd window and enter the path of the executable with an argument. The argument being the full path including the filename.. The executable has the FileChanegDir() function called in and it retains the CMD's working dir name. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 29, 2015 Developers Share Posted May 29, 2015 Call me slow but I still don't understand. Isn't FileChanegDir() changing it for subsequent commands performs in your script?Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Karan Posted May 29, 2015 Author Share Posted May 29, 2015 Sorry if I didn't explain it right.I open a Command window and execute my script with an argument as:cmd ->C:\abc\> "C:\folder\my.exe" "c:\xyz\input.file"In the executable "my.exe":FileChangeDir($CmdLine[1]) MsgBox(0,"",@WorkingDir)The messagebox instead of displaying C:\xyz, it displays C:\abc when I open the cmd and execute. Whereas when I drag and drop the input.file on to the icon of my.exe, the messagebox reads C:\xyz Link to comment Share on other sites More sharing options...
argumentum Posted May 29, 2015 Share Posted May 29, 2015 "c:\xyz\input.file"is not a folder Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Karan Posted June 1, 2015 Author Share Posted June 1, 2015 understood. But how does drag and drop work when the input file is dragged on the executable? The argument it gets is still the same .. . Link to comment Share on other sites More sharing options...
Developers Jos Posted June 1, 2015 Developers Share Posted June 1, 2015 (edited) I assume that the initial workdir is set to the directory of the file being dragged-and-dropped and not the script dir.Try this one to check that:MsgBox(0,"",@WorkingDir) FileChangeDir($CmdLine[1]) MsgBox(0,"",@WorkingDir)Jos Edited June 1, 2015 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
argumentum Posted June 1, 2015 Share Posted June 1, 2015 (edited) $varDrag_Drop_Toss_howEver = "c:\xyz\input.file" If StringInStr(FileGetAttrib($varDrag_Drop_Toss_howEver), "D") Then ; is a folder FileChangeDir($varDrag_Drop_Toss_howEver) Else ; is NOT a folder , therefore we need to remove the file name from the full path to FileChangeDir FileChangeDir(StringLeft($varDrag_Drop_Toss_howEver, StringInStr($varDrag_Drop_Toss_howEver, '\', 0, -1) - 1)) EndIf Edited June 1, 2015 by argumentum fix the example :/ Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. 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