| View previous topic :: View next topic |
| Author |
Message |
arbe
Joined: 12 Apr 2005 Posts: 30
|
Posted: Mon Mar 06, 2006 7:49 pm Post subject: Run command and links with command line parameters |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Mon Mar 06, 2006 10:56 pm Post subject: |
|
|
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Tue Mar 07, 2006 4:20 am Post subject: |
|
|
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 |
|
 |
arbe
Joined: 12 Apr 2005 Posts: 30
|
Posted: Tue Mar 07, 2006 8:02 am Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Tue Mar 07, 2006 2:51 pm Post subject: |
|
|
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 |
|
 |
|