| View previous topic :: View next topic |
| Author |
Message |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Sun Jul 27, 2008 9:28 pm Post subject: Run Command |
|
|
Is it possible to pass an argument with the run command?
I have a script that reads the first command line argument for processing. I wan tto call this script from another script, but I don't see how to include the filename argument with the run command _________________ Brion |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 139
|
Posted: Sun Jul 27, 2008 9:43 pm Post subject: |
|
|
What is your code for this? _________________ Have trouble searching the site for information? Try Quick Search for Autohotkey. |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 970 Location: London, UK
|
Posted: Sun Jul 27, 2008 9:43 pm Post subject: |
|
|
| Quote: | | To pass parameters, add them immediately after the program or document name. If a parameter contains spaces, it is safest to enclose it in double quotes (even though it may work without them in some cases). |
_________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Sun Jul 27, 2008 10:04 pm Post subject: |
|
|
Here is teh code form my test script:
;Var to hold files we are working with
DBfiles = test1, test2, test3
loop, parse, DBfiles, ,
{
currentfile= %A_Loopfield%
Run, c:\script\DBcopy.ahk %currentfile%
}
I get an error:
Error: Faild attampt to launch program or document:
Action: <c:\script\DBcopy.ahk test1>
Params: <> _________________ Brion |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Sun Jul 27, 2008 10:15 pm Post subject: |
|
|
First off, make sure that the file C:\script\DBcopy.ahk exists (I'm assuming it does).
You might also try enclosing the parameters and/or filename in double quotes:
| Code: |
"Run, c:\script\DBcopy.ahk" "%currentfile%" |
|
|
| Back to top |
|
 |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Sun Jul 27, 2008 10:25 pm Post subject: |
|
|
Thank you for the sugestions.
-Yes, the file does exist, and if I take off the argument, it runs (but of course then there is no file to work on).
-I tried the quotes adn got the following error:
Line text: "Run, c:\script\DBcopy.ahk" "%CurrentFile%"
Error: This line does not contain a recognized action. _________________ Brion |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Sun Jul 27, 2008 10:33 pm Post subject: |
|
|
Oops...
Run, "c:\script\DBcopy.ahk" "%CurrentFile%"
Quote in the wrong spot  |
|
| Back to top |
|
 |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Sun Jul 27, 2008 10:48 pm Post subject: |
|
|
I get the same error with and without quotes. I am also seeing another error that comes up prior to the one quoted above.
Error:
The procedure entry point GetProcessImageFileNameW could not be located in the dynamic link library PSAPI.DLL _________________ Brion |
|
| Back to top |
|
 |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Sun Jul 27, 2008 10:54 pm Post subject: |
|
|
The new error only come up if I use the qutoes _________________ Brion |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 970 Location: London, UK
|
Posted: Sun Jul 27, 2008 11:07 pm Post subject: |
|
|
looks to me like the currentfile variable is blank, check it with a message biox before you try the run command. _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Sun Jul 27, 2008 11:15 pm Post subject: |
|
|
The currentfile var is fine, containing the first file test1
If you look at the action line from the error mentionded above:
Action: <c:\script\DBcopy.ahk test1>
It looks to me like the line is being rendard properly, just dosen't like the arg. _________________ Brion |
|
| Back to top |
|
 |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Sun Jul 27, 2008 11:19 pm Post subject: |
|
|
When I go into help, it say that I am using version 1.0.38.03. Would a newer version fix this problem? _________________ Brion |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6847 Location: Pacific Northwest, US
|
Posted: Sun Jul 27, 2008 11:29 pm Post subject: |
|
|
it wouldn't hurt. there are many good features added since then _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1496
|
Posted: Sun Jul 27, 2008 11:32 pm Post subject: |
|
|
| Code: | ;Var to hold files we are working with
DBfiles = test1, test2, test3
loop, parse, DBfiles, ,
{
currentfile= %A_Loopfield%
Run, %A_Ahkpath% "c:\script\DBcopy.ahk" "%currentfile%"
} |
Manual: Passing Command Line Parameters to a Script _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
briona
Joined: 24 Jul 2008 Posts: 18 Location: MN
|
Posted: Mon Jul 28, 2008 12:07 am Post subject: |
|
|
Thank you everyone for your help! I think we finally got it!
In the end it looks like it took 2 things to fix it:
1) upgrading Auto Hotkey
2) chaning teh run line to as follows:
Run, %A_Ahkpath% c:\script\DBcopy.ahk %currentfile%
What dose the %A_Ahkpath% do in this command? _________________ Brion |
|
| Back to top |
|
 |
|