AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Run Command
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Sun Jul 27, 2008 9:28 pm    Post subject: Run Command Reply with quote

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
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 139

PostPosted: Sun Jul 27, 2008 9:43 pm    Post subject: Reply with quote

What is your code for this?
_________________
Have trouble searching the site for information? Try Quick Search for Autohotkey.
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 970
Location: London, UK

PostPosted: Sun Jul 27, 2008 9:43 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Sun Jul 27, 2008 10:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Sun Jul 27, 2008 10:15 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Sun Jul 27, 2008 10:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Sun Jul 27, 2008 10:33 pm    Post subject: Reply with quote

Oops...
Run, "c:\script\DBcopy.ahk" "%CurrentFile%"

Quote in the wrong spot Mad
Back to top
View user's profile Send private message AIM Address
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Sun Jul 27, 2008 10:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Sun Jul 27, 2008 10:54 pm    Post subject: Reply with quote

The new error only come up if I use the qutoes
_________________
Brion
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 970
Location: London, UK

PostPosted: Sun Jul 27, 2008 11:07 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Sun Jul 27, 2008 11:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Sun Jul 27, 2008 11:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6847
Location: Pacific Northwest, US

PostPosted: Sun Jul 27, 2008 11:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
[VxE]



Joined: 07 Oct 2006
Posts: 1496

PostPosted: Sun Jul 27, 2008 11:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
briona



Joined: 24 Jul 2008
Posts: 18
Location: MN

PostPosted: Mon Jul 28, 2008 12:07 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group