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 

Why does AutoHotkey Run command have this design goal?

 
Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
deleyd



Joined: 08 Mar 2008
Posts: 64
Location: Santa Barbara

PostPosted: Sat Jun 13, 2009 12:11 am    Post subject: Why does AutoHotkey Run command have this design goal? Reply with quote

Why does the AutoHotkey Run command have this design goal:
  • User can launch a document name containing spaces without having to enclose it in double quotes.
This design decision is preventing users from passing parameters to script files. e.g. you can't do:
Code:
Run, MyScript.vbs param1 param2 param3
  • It's easy to enclose a filename containing spaces in double quotes
  • The DOS command prompt requires double quotes around a file name containing spaces
  • This goal prevents the AutoHotkey Run command from working like a DOS line mode command. Specifically, users can not pass parameters to scripts.
I know there are ugly workarounds, such as using %comspec%, which causes a DOS window to temporarily flash onto the screen.
Back to top
View user's profile Send private message Visit poster's website
Krogdor



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

PostPosted: Sat Jun 13, 2009 2:05 am    Post subject: Re: Why does AutoHotkey Run command have this design goal? Reply with quote

deleyd wrote:
I know there are ugly workarounds, such as using %comspec%, which causes a DOS window to temporarily flash onto the screen.

You can run the window as hidden by specifying that in the Run options.
Back to top
View user's profile Send private message AIM Address
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Sat Jun 13, 2009 7:44 am    Post subject: Reply with quote

Perhaps Run should behave like CreateProcess:
Quote:
The lpApplicationName parameter can be NULL. In that case, the module name must be the first white space–delimited token in the lpCommandLine string. If you are using a long file name that contains a space, use quoted strings to indicate where the file name ends and the arguments begin; otherwise, the file name is ambiguous. For example, consider the string "c:\program files\sub dir\program name". This string can be interpreted in a number of ways. The system tries to interpret the possibilities in the following order:
    c:\program.exe files\sub dir\program name
    c:\program files\sub.exe dir\program name
    c:\program files\sub dir\program.exe name
    c:\program files\sub dir\program name.exe
Source: MSDN: CreateProcess Function
I suppose it would just need to test each space-delimited substring as is before appending ".exe".

Comments in the AutoHotkey source code say (about CreateProcess, which is used by Run for executable files):
Code:
         // MSDN: "If [lpCurrentDirectory] is NULL, the new process is created with the same
         // current drive and directory as the calling process." (i.e. since caller may have
         // specified a NULL aWorkingDir).  Also, we pass NULL in for the first param so that
         // it will behave the following way (hopefully under all OSes):
"the first white-space – delimited
         // token of the command line specifies the module name. If you are using a long file name that
         // contains a space, use quoted strings to indicate where the file name ends and the arguments
         // begin (see the explanation for the lpApplicationName parameter). If the file name does not
         // contain an extension, .exe is appended. Therefore, if the file name extension is .com,
         // this parameter must include the .com extension. If the file name ends in a period (.) with
         // no extension, or
if the file name contains a path, .exe is not appended. If the file name does
         // not contain a directory path, the system searches for the executable file in the following
         // sequence...".

I suppose the red text is no longer accurate for "current" versions of Windows.
Back to top
View user's profile Send private message Visit poster's website
n-l-i-d
Guest





PostPosted: Sun Jun 21, 2009 8:34 pm    Post subject: Reply with quote

Code:
Run, cscript.exe //nologo "MyScript.vbs" "something" "somethingelse" "param3", , Hide

;or

myscript = MyScript.vbs
param1 = something
param2 = somethingelse

Run, cscript.exe //nologo "%myscript%" "%param1%" "%param2%" "param3", , Hide
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Wish List 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