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 and links with command line parameters

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
arbe



Joined: 12 Apr 2005
Posts: 30

PostPosted: Mon Mar 06, 2006 7:49 pm    Post subject: Run command and links with command line parameters Reply with quote

Hi Chris,

I experience the following bug:

I have a windows shortcut/link file called c:\test.lnk.
It is set to "c:\text.exe abc" (without the quotation marks and containg just that one space in the middle).

Now this line in AHK
Run, c:\test.lnk
does launch test.exe correctly, but it passes "abc " (with one trailing space) as command line parameter. That screws up my application.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Mon Mar 06, 2006 10:56 pm    Post subject: Reply with quote

Thanks for the report. I'm going to look into it, but a fix might be unlikely. This is because internally, AHK simply calls the OS's ShellExecute() function to launch a shortcut (.lnk file). It does not look in the shortcut file or change it in any way.
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Mar 07, 2006 4:20 am    Post subject: Reply with quote

I tried to reproduce it but couldn't. I created a compiled script to report incoming parameters:

Code:
MsgBox %0% parameters
Loop %0%
{
   Param := %A_Index%
   MsgBox Parameter #%A_Index% is: "%Param%"
}

Then I made a shortcut to it, specifying c:\text.exe abc just like you did. Running the shortcut from another script doesn't show any extra space at the end of the parameter. This test was run on Windows XP sp2.

Perhaps you could double-check everything and/or try the test on another PC. Thanks.
Back to top
View user's profile Send private message Send e-mail
arbe



Joined: 12 Apr 2005
Posts: 30

PostPosted: Tue Mar 07, 2006 8:02 am    Post subject: Reply with quote

Hi Chris,

thanks for looking into it.

> AHK simply calls the OS's ShellExecute()
> function to launch a shortcut (.lnk file)

There must be some kind of difference, since I tried the exact same thing (calling ShellExecute()) in Visual Basic. The problem does not show up there.

I did look into your script and it works fine for me as well. This is probably due to the separation of command line parameters into %1%, %2% and so on. It is no surprise to me that this separation code looses unnecessary spaces in a good implementation. Unfortunately, many softare authors write their own code and the separation is messed up by that space.

I will send you a little testing exe file to support@autohotkey.com. It is written in VB and encloses the entire command line string (no separation at all) in underscores. If you do not load executables sent by users due to virus protection (which I could understand), I would ask you to test with TightVnc 1.2.9 Viewer and the "best-compression" link it creates during setup. This is the application that fails to launch via Rajat's 320mph on my XP sp2 machine.

Thanks a lot for your help, Chris!
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Mar 07, 2006 2:51 pm    Post subject: Reply with quote

Thanks for being persistent and for giving these extra details. I will look into it more.

Edit: This has been fixed in v1.0.42.06. The problem was that ShellExecute's "lpParameters" should be set to NULL rather than the empty string.

Thanks for sending the test program, which made it much easier to reproduce and fix this.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
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